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

ERROR1698(28000):Access denied for user root@localhost

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

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

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';

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

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄