# vim
/etc/my.cnf
[mysqld]
skip-grant-tables
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
# /usr/bin/mysql
mysql> use mysql ;
mysql> update user set password=password(‘new-password‘) where User=‘root‘;
mysql> flush privileges ;
mysql> \q
Bye
# vim
/etc/my.cnf
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
原文地址:http://hiyang.blog.51cto.com/10728919/1775779