mysql忘记密码的重置方法

1. 编辑mysql主配置文件 my.cnf
vim /etc/my.cnf
在[mysqld]字段下的位置添加参数
skip-grant
保存退出
2. 重启数据库服务
service mysqld restart
3. 这样就可以进入数据库不用授权了
mysql -uroot
4. 修改相应database的用户密码
use mysql;
update user set password=password(‘your password’) where user=’root';
5. 修改/etc/my.cnf 去掉 skip-grant , 重启mysql服务

ps:同理也可以更改其他的 如wordpress,discuz库的密码,

1,mysql -u-p密码 ;进入mysql
2,use wordpress;
3,update wp_users set user_pass=MD5(‘新密码’) where wp_users.user_login=’用户';
4,flush privileges;
5,退出mysql 并重启mysqld服务

原文地址:https://www.cnblogs.com/dantes91/p/4671052.html