连接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