windows下mysql5.7忘記密碼情況下重置密碼問題暨Access denied for user 'root'@'localhost'問題解決方案

1、停止mysql服務,修改my.ini,設置無密碼登錄

(注:mysql5.7的data目錄及my.ini默認在此目錄:C:\ProgramData\MySQL\MySQL Server 5.7。)

修改內容:在[mysqld]下增加skip-grant-tables,增加後重新mysql服務。

2、打開cmd,運行mysql -u root,進入mysql命令行

3、運行以下命令,重置密碼:

 1)、update user set authentication_string=password("newpassword") where user="root"

 2)、flush privileges

(注,5.7之前版本,user表中authentication_string字段爲password,5.7版本改爲了authentication_string。)

4、停止mysql服務,爲安全起見,將my.ini中skip-grant-tables項去掉

5、啓動mysql服務,用mysql -u root -p以及新密碼登錄

6、若登錄依然提示Access denied for user 'root'@'localhost',重複步驟1~5。



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