centos系統mysql忘記密碼


安裝 mysql 之后,注意添加軟連接

mysql 忘記密碼操作,

vim /etc/my.cnf

在 [mysqld] 的段中加上一句:skip-grant-tables

重啟 mysql 服務, service mysql restart

在輸入 mysql -u root -p  輸入回車即可進入 mysql 數據庫

use mysql;

低版本修改:update user set Password = password('LDtianzhe.') where user = 'root';

高版本修改:update user set authentication_string=password('new password') where user = 'root';

再次vim /etc/my.cnf 注釋掉 上面添加的重啟服務即可再次進入數據庫

如果出現此錯誤:

ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
需要關閉保護模式

再次使用更新密碼即可

退出,注釋掉 skip-grant-tables

重啟服務即可

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM