一,卸载自带MySQL
yum remove -y mysql mysql-devel mysql-server
二,安装MySQL-5.6.26
[root@localhost ~]# cd /usr/src/
[root@localhost src]# tar zxf mysql-5.6.26.tar.gz
[root@localhost src]# cd mysql-5.6.26
三.创建MySQL管理用户
[root@localhost mysql-5.6.26]# useradd -u 8003 -M -s /sbin/nologin mysql
四,安装MySQL编译工具依赖
[root@localhost mysql-5.6.26]# yum -y install ncurses-devel cmake
五,进行编译安装
[root@localhost mysql-5.6.26]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql
[root@localhost mysql-5.6.26]# make && make install
六,进行授权
[root@localhost mysql-5.6.26]# chown -R mysql:mysql /usr/local/mysql/
七,拷贝MySQL配置文件
[root@localhost mysql-5.6.26]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
八,拷贝MySQL启动文件
[root@localhost mysql-5.6.26]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
进行修改myql的启动配置文件
[root@localhost ~]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
九,加入MySQL开机自启
[root@localhost ~]# chkconfig mysqld on
十,初始化数据库
[root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
十一,启动MySQL服务
[root@localhost ~]# service mysqld start
十二,添加MySQL相关命令的路径
[root@localhost ~]# echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile
[root@localhost ~]#source /etc/profile