Linux Centos7 Mysql 忘記密碼怎麼找回密碼

1,跳過數據庫權限驗證

mysqld --skip-grant-tables --user=mysql &   

2,

            systemctl restart mysqld

正常情況是起不來 的等個大概10秒ctrl + c終止

3,輸入mysql 即可進入

4,修改新密碼

UPDATE mysql.user SET authentication_string=password('new_password')
WHERE user='root' AND host='localhost';  

5,刷新授權表

    FLUSH PRIVILEGES;   刷新授權表

6,exit 退出數據庫重新用新密碼登錄,即可登錄成功
7,最好reboot重啓一下,使mysql變爲運行狀態

注意:報錯處理

問題1:ERROR You must reset your password using ALTER USER statement before executing this statement

解決方案:ALTER USER 'root'@'localhost' IDENTIFIED BY 'xinmima';

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章