1.如果您没有忘记密码的情况下,可以通过UPDATE直接编辑user表来修改密码: 进入数据库MysqL -u root MysqL> use MysqL; MysqL> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root'; MysqL> FLUSH PRIVILEGES; 2.如果您已经忘记密码: # /etc/init.d/MysqL stop 1、结束当前正在运行的MysqL进程。 # /usr/bin/MysqLd_safe --skip-grant-tables 2、用MysqL安全模式运行并跳过权限验证。 # MysqL -u root 3、重开一个终端以root身份登录MysqL。 MysqL> use MysqL; 4、修改root用户口令。 Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MysqL> update user set Password = PASSWORD('root') where User ='root'; Query OK,3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 MysqL> exit # /etc/init.d/MysqL restart 5、结束MysqL安全模式,用正常模式运行MysqL。 MysqL> update MysqL.user set password=PASSWORD('新密码') where User='root'; 6、试试你新修改的口令 MysqL> flush privileges; MysqL> quit