1、编辑MySQL的配置文件:
liunx下:/etc/my.cnf
win: my.ini
在此配置文件[msyqld]中添加如下一行: skip-grant-tables 保存退出编辑。2、然后重启MySQL服务
/etc/init.d/mysqld restart
mysql -uroot -p
不用密码就可进去
4 修改表
1> use mysql;
2>update user set password=PASSWORD("root") where user='root';
5 还原配置文件my.cnf
把 1 中 添加的 skip-grant-tables 去掉 并重启