在centos6.8上源码安装了MySQL5.7.20,进入mysql的时候报错如下:

MySQL5.7.20报错Access denied for user 'root'@'localhost' (using password: NO)

 

解决办法如下:

在mysql的配置文件内加入:

vim  /etc/my.cnf

skip-grant-tables

保存并重启mysql服务

 

进入mysql,修改密码:

mysql> use mysql;

mysql> update user set password=password("你的新密码") where user="root";

mysql> flush privileges;

mysql> quit

到此root账户就重置了密码,删除etc/my.cnf中,刚添加的那行内容,重启mysql就好了

 

 

如果在进行到

mysql> update user set password=password("你的新密码") where user="root";

报错:ERROR 1054 (42S22): Unknown column 'password' in 'field list'

解决措施如下:

mysql>desc user;

发现在Field列中没有password,此时我们需要这样重置密码:

mysql>update user set authentication_string=password('你的新密码') where user='root';

之后的步骤如上所示,就解决了这个问题

相关文章:

  • 2021-08-16
  • 2021-08-01
  • 2021-10-17
  • 2021-06-08
  • 2021-07-21
  • 2022-12-23
  • 2021-08-14
猜你喜欢
  • 2021-07-12
  • 2022-02-19
相关资源
相似解决方案