第二次安装会安装失败
1.先停止mysql服务 service mysql stop
2.检查是否卸载干净 find / -name mysql 多用几个命令检查,不要删到其他组件的
3.检查mysql进程是否结束 ps -aux | grep mysql
1.解压文件
[root@centos3 ~]# tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
2.重命名
[root@centos3 ~]# cd /usr/local/
[root@centos3 local]# mv mysql-5.7.19-linux-glibc2.12-x86_64/ mysql
3.配置环境变量
[root@centos3 local]# vi + /etc/profile
[root@centos3 local]# source /etc/profile
4.创建组和用户并授权
[root@centos3 local]# groupadd mysql
[root@centos3 local]# useradd -r -g mysql -s /bin/false mysql
[root@centos3 local]# chown -R mysql mysql/
[root@centos3 local]# chgrp -R mysql mysql/
5.初始化并记住最后的12位密码
[root@centos3 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/目录下
[root@centos3 local]# cd /usr/local/mysql/support-files/
[root@centos3 support-files]# vi mysql.server
[root@centos3 support-files]# cp mysql.server /etc/init.d/mysqld
7.重命名my.cnf
[root@centos3 support-files]# mv /etc/my.cnf /etc/my_default.cnf
8.设置开机启动
[root@centos3 support-files]# chmod +x /etc/init.d/mysqld
[root@centos3 support-files]# chkconfig --add mysqld
[root@centos3 support-files]# chkconfig mysqld on
//查看开机启动是否成功
[root@centos3 support-files]# chkconfig --list mysqld
9.启动服务
[root@centos3 support-files]# /etc/init.d/mysqld start
[root@centos3 support-files]# service mysql start
10.登录修改密码,密码就是第5步系统生成的
[root@centos3 support-files]# mysql -uroot -p
mysql> set password=password("1234");