前提可能要先装 autoconf


1. 下载二进制mysql的安装包

[root@minion-1 ~]#wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz

2. 新建mysql用户一个专放软件的目录

[root@minion-1 ~]#useradd mysql && mkdir -p /services/current_apps

3. 解压包到放软件的目录下

[root@minion-1 ~]# tar -xzf mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz -C /services/current_apps

4. 进入目录 拷贝服务的模板文件

[root@minion-1 ~]# cd /services/current_apps/mysql-5.6.42-linux-glibc2.12-x86_64/ && cp support-files/mysql.server /etc/init.d/mysqld && cp support-files/my-default.cnf /etc/my.cnf

5. 修改两个参数,稍后用作数据目录和mysql安装目录

[root@minion-1 mysql-5.6.42-linux-glibc2.12-x86_64]# vi /etc/init.d/mysqld
#If you change base dir, you must also change datadir. These may get
overwritten by settings in the MySQL configuration files.

basedir=/usr/local/mysql
datadir=/data/mysql

6. 新建data数据目录并软连接

[root@minion-1 mysql-5.6.42-linux-glibc2.12-x86_64]# mkdir /data && ln -s /services/current_apps/mysql-5.6.42-linux-glibc2.12-x86_64/ /usr/local/mysql

7. 初始化mysql的数据目录

[root@minion-1 mysql-5.6.42-linux-glibc2.12-x86_64]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

8. 把mysqld服务加入服务并启动

[root@minion-1 mysql-5.6.42-linux-glibc2.12-x86_64]# chkconfig --add mysqld &&service mysqld start

9. 确认服务mysql的确开启,返回1说明开了

[root@minion-1 mysql-5.6.42-linux-glibc2.12-x86_64]# netstat -tupln|grep 3306|wc -l
1

10. 添加环境变量

[root@minion-3 mysql-5.6.42-linux-glibc2.12-x86_64]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh && source /etc/profile

11. 设置密码

[root@minion-3 mysql-5.6.42-linux-glibc2.12-x86_64]# mysqladmin -uroot -p password 'll'
Enter password: