Ubuntu16.04 ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决流程

时间:2023-11-12 22:45:44

mysql版本 5.7.22

Ubuntu16.04  ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决流程

安装完成后出现问题

ERROR 1698 (28000): Access denied for user 'root'@'localhost'

可能是因为初始密码为空;按空格回车后还是报一样的错

那只能使用mysql -udebian-sys-maint -p进入MySQL,这时你需要mysql提供给你的密码

输入 sudo vim /etc/mysql/debian.cnf 
Ubuntu16.04  ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决流程

password就是密码

进入后重新设置root账号密码UPDATE user SET authentication_string=PASSWORD('你的密码') where USER='root';

Ubuntu16.04  ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决流程

退出重启服务后还是报错!但是密码还是改成功了,查看select user,plugin from  user

Ubuntu16.04  ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决流程

错误原因是因为 plugin root 的字段是auth_socket 改掉就行

update user set authentication_string =password('你的密码'),plugin='msyql_native_password' where user='root'

Ubuntu16.04  ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决流程

niec 现在exit  退出

Ubuntu16.04  ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决流程

可以了

参考文章:https://www.cnblogs.com/leolztang/p/5094930.html