1、安装时执行语句:sudo rpm -ivh mysql80-community-release-el7-6.noarch.rpm
报错:Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
解决:rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
2、安装完成后,无法登录
解决:vi /etc/my.cnf,在文件最后加入:skip-grant-tables,跳过校验,此时密码为空,回车即可登录。
3、修改密码
网上常见的方法如下,我这里不可行
登录mysql后执行
use mysql;
update user set password=password('1234') where user='root';
新版本password字段改为authentication_string
update user set authentication_string=password('1234') where user='root';
使用均报错:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('新密码') where user='root'' at line 1
之后执行
flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';
此时报错: Your password does not satisfy the current policy requirements,意为密码过于简单,不符合密码策略。
此时输入语句 " SHOW VARIABLES LIKE 'validate_password%'; "进行查看
可见策略等级为medium中级,长度为8,
此时执行修改: set global validate_password_policy=LOW;
报错:
因此需要先设置一个符合条件的代码,执行语句:
alter user 'root'@'%' identified with mysql_native_password by 'Root_1234';
之后再修改策略
set global validate_password.policy=0;
set global validate_password.length=1;
修改成功如图
此时可将密码改回