zl程序教程

您现在的位置是:首页 >  .Net

当前栏目

[MySQL] 解决Error 1698: Access denied for user 'root'@'localhost'

2023-02-18 15:41:50 时间

当程序中使用root账号连接mysql时报以下错误,但是使用命令行是可以正常连接的,那么就查询下mysql数据库的user表,查看下当前用户的密码加密方式,看看是不是unix_socket
MariaDB [mysql]> select user,plugin from user;
+------+-------------+
| user | plugin |
+------+-------------+
| root | unix_socket |
+------+-------------+
可以更改下用户的加密方式:
update user set authentication_string=password("123456"),plugin='mysql_native_password' where user='root';