ubuntu 忘記mysql 密碼解決方法


一段時間沒有用mysql數據庫,今天突然需要使用,結果忘記密碼,google了下找到的解決方法,就順便記錄下,下次碰到就不需要這么麻煩了

1、輸入命令  cat /etc/mysql/debian.cnf 

 

 

2、使用賬號 debian-sys-maint 賬號登錄mysql密碼為 debian.cnf 中password 值(# password 值每個人的情況不一樣,根據實際情況),在切換到mysql

 

3、修改root賬號密碼(自己方便修改為123456了)

 update mysql.user set authentication_string=password('123456') where user='root' and Host='localhost';

update user set plugin='mysql_native_password';

flush privileges;

 

 4、修改密碼后登錄

mysql -u root -p

 


免責聲明!

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



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