准备工作:
1.查看是否有安装过mysql
rpm -qa | grep -i mysql
2.删除mysql
yum -y remove MySQL-*
3.把所有出现的目录统统删除
find / -name mysql
4.删除配置文件
rm -rf /etc/my.cnf
5.删除mysql的默认密码
rm -rf /root/.mysql_sercret
开始安装:
1.配置Mysql 8.0安装源
sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
2.安装Mysql 8.0
sudo yum --enablerepo=mysql80-community install mysql-community-server
3.启动mysql服务
service mysqld start
4.查看mysql服务运行状态
service mysqld status
5.查看root临时密码
grep "A temporary password" /var/log/mysqld.log
6.更改临时密码
先看看当前的密码验证策略
输入:
SHOW VARIABLES LIKE ‘validate_password.%’;
策略说明
validate_password.length 是密码的最小长度,默认是8,我们把它改成6
输入:
set global validate_password.length=6;
validate_password.policy 验证密码的复杂程度,我们把它改成0
输入:
set global validate_password.policy=0;
validate_password.check_user_name 用户名检查,用户名和密码不能相同,我们也把它关掉
输入:
set global validate_password.check_user_name=off;
刷新配置:
flush privileges;
执行修改密码的命令
输入:
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘12345’;
或者
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345';
密码设成功
7.配置远程访问
create user 'root'@'%' identified with mysql_native_password by 'root';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
注意:本文归作者所有,未经作者允许,不得转载