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

连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决方法

 

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

表示不用密码就可以登录。

3、打开电脑的服务,重启MySQL服务。

4、进入MySQL命令行

连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决方法

 

 不用输入密码,直接进入

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服务,即可。

 

相关文章:

  • 2022-12-23
  • 2022-01-30
  • 2021-04-16
  • 2021-09-11
  • 2021-07-03
猜你喜欢
  • 2022-12-23
  • 2021-05-23
  • 2021-06-15
  • 2021-04-28
  • 2021-10-10
  • 2021-05-09
  • 2022-12-23
相关资源
相似解决方案