今天拿出以前的老机器,发现Mysql的密码早已忘的一干二净。搜了一下解决方案,发现下面的办法真实有效,共享之:
/etc/init.d/mysql stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';mysql> FLUSH PRIVILEGES;
mysql> quit
/etc/init.d/mysql restartmysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>