Welcome

首页 / 数据库 / MySQL / mysql忘记root密码的恢复方法

mysql忘记root密码的恢复方法2014-01-08mysql的root忘记,现无法操作数据库

停止mysql服务service  mysql stop

或者是ps -ef |grep mysql|xargs kill -9

然后使用如下的参数启动mysql, --skip-grant-tables会跳过mysql的授权

shell#/usr/bin/mysqld_safe --skip-grant-tables &

mysql -p  回车,进入不需要密码

mysql>

mysql>update mysql.user set Password=password("itnihao") where User="root";

Query OK, 4 rows affected (0.00 sec)

Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

重启mysql,

service  mysql stop 或者是ps -ef |grep mysql|xargs kill -9

mysql -p

然后输入密码,至此,mysql密码已经修改完毕

本文出自 “itnihao的运维技术博客” 博客,请务必保留此出处http://itnihao.blog.51cto.com/1741976/77312

查看本栏目更多精彩内容:http://www.bianceng.cn/database/MySQL/