一、下载mysql5.6
地址:https://dev.mysql.com/downloads/mysql/5.6.html#downloads
二、准备
创建mysql用户
~]# useradd mysql
三、安装
1、上传到服务器中并解压
~]# tar zxvf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz ~]# mv mysql-5.6.40-linux-glibc2.12-x86_64 mysql56-3306
2、授权
~]# chown -R mysql.mysql ./
3、初始化
~]# cd mysql56-3306 mysql56-3306]# scripts/mysql_install_db --user=mysql --datadir=/home/mysql/mysql56-3306/data --basedir=/home/mysql/mysql56-3306/
注:如初出项下列情况
FATAL ERROR: please install the following Perl modules before executing scripts/mysql_install_db: Data::Dumper
安装autoconf库即可
mysql56-3306]# yum -y install autoconf
4、编辑my.cnf文件
[mysqld] basedir = /home/mysql/mysql56-3306 datadir = /home/mysql/mysql56-3306/data port = 3306 socket = /home/mysql/mysql56-3306/socket/mysql.sock pid-file = /home/mysql/mysql56-3306/pid/mysql.pid log-error = /home/mysql/mysql56-3306/logs/mysql.log user = mysql character-set-server=utf8 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
5、创建文件
mysql56-3306]# mkdir socket pid logs mysql56-3306]# touch socket/mysql.sock pid/mysql.pid logs/mysql.log mysql56-3306]# chown -R mysql.mysql ./
6、启动
mysql56-3306]# bin/mysqld_safe --defaults-file=my.cnf &
7、停止
mysql56-3306]# ps -ef | grep mysql mysql56-3306]# kill 25152 24977
8、其他
mysql56-3306]# bin/mysql -h 127.0.0.1 -uroot -p mysql> set password=password('123456'); mysql> grant all on *.* to root@'%' identified by '123456'; mysql> flush privileges;