Mysql 找回密码

1.修改配置文件
[mysqld]
# 跳过密码验证
skip-grant-tables


2.重启mysql
# 重启mysql


3.修改密码
# 配置密码
# 使用初始化时修改密码的语句修改相应用户的密码:
ALTER USER 'root'@'%' IDENTIFIED BY '新密码'
# 或者
mysql> use mysql;
mysql> update user set password=password('password') where User='root';

# 如果修改不了,则使用一下命令修改:
update user set authentication_string = password('新密码') where  host='%' and  host='localhost';  

# 最后刷新权限
mysql> flush privileges;


4.改回配置文件
[mysqld]
# 跳过密码验证
# skip-grant-tables


5.重启mysql


6.登录测试