vi /etc/my.cnf
在[mysqld]的段中加上一句 skip-grant-tables
service mysqld restart
进入mysql # mysql -u root mysql
mysql> USE mysql ;
UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ;
mysql> flush privileges ;
exit
将MySQL的登录设置修改回来
# vi /etc/my.cnf
将刚才在[mysqld]的段中加上的skip-grant-tables删除
保存并且退出vi。
重新启动mysqld
service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]