1、如果当前的MySQL正在运行,首先杀掉: killall -TERM mysqld。

2、启动MySQL: mysqld_safe --skip-grant-tables &

之后我们输入(这里不需要输入密码就可以进入):  mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.45-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

然后就是

>use mysql

>update user set password=password("new_pass") where user="root";

>flush privileges;

重新杀MySQL,用正常方法启动MySQL 。