連接mysql報錯:Access denied for user ‘root’@‘localhost’(using password: YES)的解決方法


linux系統

1,在Linux,先進入/etc,修改my.cnf,任意一行加上"skip-grant-tables"。

2,重啟MySQL:service mysqld restart

3,use mysql;

update mysql.user set authentication_string=password('your new password') where user='root';

4,flush privileges;

 

        exit;
5,重啟MySQL:service mysqld restart  (這步可以省略)

 

windows系統

版本是5.7

1、默認安裝地址:C:\ProgramData\MySQL\MySQL Server 5.7

 

 2、打開my.ini,在mysqld下面加上  skip-grant-tables

表示不用密碼就可以登錄。

3、打開電腦的服務,重啟MySQL服務。

4、進入MySQL命令行

 

 不用輸入密碼,直接進入

5、use mysql;

update mysql.user set authentication_string=password('your new password') where user='root';

flush privileges;

6、再回到my.ini,給skip-grant-tables加上“#”,表示注釋掉。

7、重啟MySQL服務,即可。

 


免責聲明!

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



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