Navicat Tips2 ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘

ERROR 1698 (28000): Access denied for user ‘root’@'localhost’
转载自学习

  • 进入以下文件
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

在如下位置,加入skip-grant-tables在这里插入图片描述
保存并退出。

  • 重启mysql
    service mysql restart

  • 重新进入mysql

mysql -u root -p
use mysql;
update user set authentication_string=password(”你的密码“)where user="root";
flush privileges; 

在这里插入图片描述

  • 再次进入mysql
service mysql restart
mysql -u root -p
  • 如下修改
use mysql;
select user,plugin from user;

从图中可以看到在执行了select user,plugin from user后,错误原因是因为plugin root的字段是auth_socket,那我们改掉它为下面的mysql_native_password就行了。
在这里插入图片描述

update user set authentication_string=password('你的密码'),plugin='mysql_natice_password' where user='root';
select user,plugin from user;
  • 此时有
    在这里插入图片描述
  • 最后注释掉之前的输入
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf 

在这里插入图片描述

  • 此时即可正常进入mysql
mysql -u root -p
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值