修改配置文件:my.cnf 加上skip-grant-tables
重启mysql
mysql -uroot 登录
mysql> USE mysql ; mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ; mysql> flush privileges ; mysql> quit
将配置文件改回来