# /etc/init.d/mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking
# mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysqld start
# mysql -u root -p
Enter password:
mysql>
以上步骤就可以免除你遗忘mysql密码的问题了,不过还是要提醒一下,最好是记住密码别忘了!