1.解压文件
[[email protected] ~]# tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
2.重命名
[[email protected] ~]# cd /usr/local/
[[email protected] local]# mv mysql-5.7.19-linux-glibc2.12-x86_64/ mysql
3.配置环境变量
[[email protected] local]# vi + /etc/profile
[[email protected] local]# source /etc/profile
4.创建组和用户并授权
[[email protected] local]# groupadd mysql
[[email protected] local]# useradd -r -g mysql -s /bin/false mysql
[[email protected] local]# chown -R mysql mysql/
[[email protected] local]# chgrp -R mysql mysql/
5.初始化并记住最后的12位密码
[[email protected] local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=zh_CN
6.修改mysql.server.文件并复制到 /etc/init.d/目录下
[[email protected] local]# cd /usr/local/mysql/support-files/
[[email protected] support-files]# vi mysql.server
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
7.重命名my.cnf
[[email protected] support-files]# mv /etc/my.cnf /etc/my_default.cnf
8.设置开机启动
[[email protected] support-files]# chmod +x /etc/init.d/mysqld
[[email protected] support-files]# chkconfig --add mysqld
[[email protected] support-files]# chkconfig mysqld on
//查看开机启动是否成功
[[email protected] support-files]# chkconfig --list mysqld
9.启动服务
[[email protected] support-files]# /etc/init.d/mysqld start
[[email protected] support-files]# service mysql start
10.登录修改密码,密码就是第5步系统生成的
[[email protected] support-files]# mysql -uroot -p
mysql> set password=password("1234");