1.先停掉mysql
# /etc/rc.d/init.d/mysqld stop
2.以--skip-grant-table 的参数启动mysql
# mysqld_safe --skip-grant-table&
3. 更改root 密碼
# mysql mysql
mysql> UPDATE user SET password=password(xxxxxxx) WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> exit
4.停掉mysql再启
killall mysqld
#/etc/rc.d/init.d/mysqld start
# mysql -u root -p
Enter password: