红联Linux门户
Linux帮助

Linux-mysql忘记root密码

发布时间:2015-09-06 15:14:33来源:linux网站作者:米刀文

长时间未用装有mysql的虚拟机,最近用的时候,忘记mysql的root密码了,然后找了一下解决方案:


1.编辑配置文件my.cnf

[mysqld]
….
skip-grant-tables


2.重新启动mysql服务、

service mysql restart


3.登录mysql修改root密码

#mysql
mysql>use mysql;
mysql> update user set password = password('newpassword') where user = 'root' ; #修改newpassword为你自己设置的密码
mysql>flush privileges ;
mysql>quit


4.恢复配置文件my.cnf
删除之前配置的skip-grant-tables


5.再次重新启动mysql即可。


Ubuntu下MySQL忘记root密码重置:http://www.linuxdiyf.com/linux/13666.html

Ubuntu15.04下MySQL5.6安装过程:http://www.linuxdiyf.com/linux/13250.html

Ubuntu 15.04安装配置Apache和mysql的方法:http://www.linuxdiyf.com/linux/13074.html

关于MySQL密码你应该知道的那些事:http://www.linuxdiyf.com/linux/12965.html

Linux mysql安装修改root密码服务:http://www.linuxdiyf.com/linux/251.html