准备工作:
网络源使用163,sohu
需要在yum.conf 中添加
exclude=kernel*
exclude=centos-release*
安装依赖包:
rpm -ivh http://mirrors.ustc.edu.cn/epel/6Server/x86_64/epel-release-6-8.noarch.rpm
tar xvfhttp://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz
yum -y install ntp cmake make openssl openssl-devel pcre pcre-devel libpng libpng-devel libtiff-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel fontconfig-devel zlib zlib-devel libevent-devel gcc gcc-c++ flex bison bzip2 bzip2-devel libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
useradd-M-s/sbin/nologinMysqL
mkdir-p/data/MysqL#存放数据库
3、解压安装MysqL
tar-zxvfMysqL-5.6.31-linux-glibc2.5-x86_64.tar.gz mvMysqL-5.6.31-linux-glibc2.5-x86_64/usr/local/MysqL cd/usr/local/MysqL make&&makeinstall
//使用cmake则需要使用CMAKE参数,以下说明:
-DCMAKE_INSTALL_PREFIX=/usr/local/MysqL //默认安装目录
-DINSTALL_DATADIR=/usr/local/MysqL/data //数据库存放目录
-DDEFAULT_CHARSET=utf8 //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci //校验字符
-DEXTRA_CHARSETS=all //安装所有扩展字符集
-DENABLED_LOCAL_INFILE=1 //允许从本地导入数据
-DMysqL_USER=MysqL
-DMysqL_TCP_PORT=3306
注意事项:
如安装失败重新编译时,需要清除旧的对象文件和缓存信息。
make clean
rm -f CMakeCache.txt
rm -rf /etc/my.cnf
4、设置目录权限并创建系统数据库的表
chown-RMysqL.MysqL/usr/local/MysqL chown-RMysqL.MysqL/data/MysqL cp/usr/local/MysqL/support-files/my-default.cnf/etc/my.cnf cp/usr/local/MysqL/support-files/MysqL.server/etc/rc.d/init.d/MysqL//将MysqL的启动服务添加到系统服务中 /usr/local/MysqL/scripts/MysqL_install_db--basedir=/usr/local/MysqL/--datadir=/data/MysqL/--user=MysqL
5、设置环境变量
vi/etc/profile exportPATH=$PATH:/usr/local/MysqL/bin:/usr/local/MysqL/lib source/etc/profile
7、开启MysqL服务
shell>serviceMysqLstart StartingMysqL.......[确定] shell>chkconfig--addMysqL//加入开机启动服务
shell>MysqL-urootMysqL MysqL>GRANTALLPRIVILEGESON*.*TOroot@"%"IDENTIFIEDBY"passwd"; QueryOK,0rowsaffected(0.09sec) MysqL>updateusersetpassword=password('passwd')whereuser='root'; MysqL>flushprivileges; QueryOK,0rowsaffected(0.00sec) MysqL>exit shell>MysqL-uroot-p Enterpassword:原文链接:/centos/382009.html