|
mysql 密码找回
第一步:修改配置文件免密码登录mysql
vim /etc/my.cnf
第二步:在 [mysqld]最后加上如下语句 并保持退出文件;
skip-grant-tables
第三步:重启mysql服务:
第四步:免密码登录到mysql上;直接在命令行上输入:
mysql -u root -p
//password直接回车
use mysql;
网上说:
update user set password=password("123456") where user="root";(5.5以前)
update user set authentication_string=("123456") where user='root'; (5.7以前)
问题来了,仍然报错。。。。。。。。。。。。。。
最后解决方案:
需要置空密码,再创建密码
update user set authentication_string='' where user='root';
第五步:
退出mysql, 删除/etc/my.cnf文件最后的 skip-grant-tables 重庆mysql服务;
第六步
使用root用户进行登录,因为上面设置了authentication_string为空,所以可以免密码登录;
mysql -u root -p
passwrod:直接回车;
第七步
mysql> ALTER user 'root'@'localhost' IDENTIFIED BY 'Qian123#' (密码规则要有大小写字母,数字,特殊字符)
mysql> flush privileges;
问题解决,终于找到密码了。。。。。。。。。。。。

设定密码错误,提示密码策略不对
输入语句 “ SHOW VARIABLES LIKE 'validate_password%'; ” 进行查看,

关于 mysql 密码策略相关参数;
1)、validate_password_length 固定密码的总长度;
2)、validate_password_dictionary_file 指定密码验证的文件路径;
3)、validate_password_mixed_case_count 整个密码中至少要包含大/小写字母的总个数;
4)、validate_password_number_count 整个密码中至少要包含阿拉伯数字的个数;
5)、validate_password_policy 指定密码的强度验证等级,默认为 MEDIUM;
关于 validate_password_policy 的取值:
0/LOW:只验证长度;
1/MEDIUM:验证长度、数字、大小写、特殊字符;
2/STRONG:验证长度、数字、大小写、特殊字符、字典文件;
6)、validate_password_special_char_count 整个密码中至少要包含特殊字符的个数;
|