use mysql;mysql> UPDATE user SET Password = PASSWORD('newpass" />
Linux MySQL密碼修改
1)如果您沒有忘記密碼的情況下,可以通過UPDATE直接編輯user表來修改密碼:
進(jìn)入數(shù)據(jù)庫mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
或者
/etc/init.d/mysql stop
/etc/init.d/mysql start
2)如果您已經(jīng)忘記密碼:
# /etc/init.d/mysql stop 1、結(jié)束當(dāng)前正在運(yùn)行的mysql進(jìn)程。
# /usr/bin/mysqld_safe --skip-grant-tables 2、用mysql安全模式運(yùn)行并跳過權(quán)限驗(yàn)證。
# mysql -u root 3、重開一個(gè)終端以root身份登錄mysql。
mysql> use mysql; 4、修改root用戶口令。
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
# /etc/init.d/mysql restart 5、結(jié)束mysql安全模式,用正常模式運(yùn)行mysql。
mysql> update mysql.user set password=PASSWORD('新密碼') where User='root';
6、試試你新修改的口令
mysql> flush privileges;
mysql> quit
bitsCN.com聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com