mysql的毛病 ERROR:1698(28000):Access denied for user root@localhost ERROR1698(28000):Access denied for user root@localhost

今天安装mysql之后发现怎么就是登录不进去,然后root用户权限就行,自己的用户就是不行,显示的是

在网上查找各种办法不行,最后在这篇博主哪里找到了方法

https://www.cnblogs.com/cpl9412290130/p/9583868.html

其中有一些问题,比如service命令找不到,需要

sudo apt install initscripts

然后就对 /etc/mysql/mysql.conf.d/mysqld.cnf进行编辑,加入skip-grant-tables,跳过验证,然后再重启服务,在非root用户权限下面可以进入mysql并进行操作

mysql>>use mysql;
mysql>>update user set authentication_string=password("你的密码") where user="root";
mysql>>flush privileges;  

 authentication_string这个字段好像是5.7以上才有,5.7一下是password

然后查看刚刚的用户

select user,plugin from user;
update user set authentication_string=password("你的密码"),plugin='mysql_native_password' where user='root';

 然后退出,将开始的跳过检查给注释掉,重启服务,就可以正常访问了

猜你喜欢

转载自www.cnblogs.com/pason-blog/p/10680807.html
今日推荐