MySQL忘记密码没法登陆

一、编辑mysql配置文件my.ini(在mysql的安装目录下,个人在D:\Program Files\MySQL\MySQL Server 5.0\my.ini),在[mysqld]这个条目下添加一行 skip-grant-tables 保存退出后重启mysql;mysql

二、cmd里面输入mysql -u root -p,登陆mysql;sql

三、进入mysql数据库数据库

mysql> use mysql; 
Database changed
ide

四、给root用户设置新密码:  
mysql> update user set password=password("xxx") where user="root"; 
Query OK, 1 rows affected (0.01 sec) 
Rows matched: 1 Changed: 1 Warnings: 0
spa

五、注释掉第1步中添加的skip-grant-tables 保存退出并重启orm

相关文章
相关标签/搜索