刚刚在网上看了下由于Linux更新,已经没有完整的更改mysql密码步骤。
我自己总结了一下。
MySQL忘记密码解决办法:
切换到root用户
1.vi/etc/my.cnf
添加 skip-grant-tables,后保存退出。
2.重启数据库systemctl restart mysqld(Linux更新后我这么用,你们随意。)
3.登陆MySQL mysql -uroot -p,密码随便输入。
4.输入USE mysql,回车。
5.输入update mysql.user set authentication_string=password('root') where user='root';,回车。
6.退出数据库\q,编辑vi/etc/my.cnf 删除skip-grant-tables,后保存退出。
7.重启数据库systemctl restart mysqld,密码root生效。
8.改密码有教程就不说了,谢谢。
参考资料:
http://www.cnblogs.com/allenblogs/archive/2010/08/12/1798247.html
http://blog.csdn.net/u010603691/article/details/50379282