ubuntu修改mysql密碼的方法:
1、在終端中結束mysql進程。
# sudo /etc/init.d/mysql stop
2.用mysql安全模式運行并跳過權限驗證。
# sudo /usr/bin/mysqld_safe --skip-grant-tables
3.重新打開一個終端頁面以root身份登錄mysql。
# mysql -u root
4.輸入修改root用戶口令,例如:
mysql> use mysql;Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set Password = PASSWORD('root') where User ='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> exit
(注:括號里的'root'就是新密碼。)
5.結束mysql安全模式,用正常模式運行mysql即可。
# sudo /etc/init.d/mysql restart