前提:
系统:centos6.9
mysql版本:mysql8.0.19
问题:
使用mysql -uroot -p 进入mysql时提示:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决过程:
1.在my.cnf,可使用whereis命令查看该文件的位置。一般在/etc下中加入 skip-grant tables
2.输入”mysql“即可进入mysql。
1)输入 use mysql
进入mysql数据库
2)使用命令 select user,host from user
查看用户表,发现不存在user用户。
3)使用 create user 'root'@'localhost' identified by '123456';
创建用户。
出错:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
4)使用flush privileges
即可解决
5)再次 create user 'root'@'localhost' identified by '123456';
创建用户。
提示: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
6)使用 show variables like 'validate_password%';
查看密码策略:
7)使用一下命令修改密码策略:
set global validate_password.policy=LOW;
set global validate_password.length=6;
8)这时再使用create user 'root'@'localhost' identified by '123456';
可行。
3.最后修改my.cnf中把 skip-grant tables
注释掉。restart mysql服务即可。