mysql8.0的默认密码验证不再是password。所以在创建用户时,create user 'username'@'%' identified by 'password'; 客户端是无法连接服务的。

 

方法一:

登录MySQL后输入:

ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

FLUSH PRIVILEGES;

 

方法二:

编辑my.cnf文件,更改默认的身份认证插件。比如说:

vim /data/mysql/mysql_3306/my_3306.cnf

# 在[mysqld]中添加下边的代码
default_authentication_plugin=mysql_native_password

这个需要重启服务才生效。

 

mysql> select user,host,plugin from mysql.user;        
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| bak              | %         | mysql_native_password |
| monitor          | %         | mysql_native_password |
| repuser          | %         | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session    | localhost | caching_sha2_password |
| mysql.sys        | localhost | caching_sha2_password |
| repuser          | localhost | caching_sha2_password |
| root             | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
8 rows in set (0.00 sec)

 




相关文章:

  • 2022-12-23
  • 2021-12-19
  • 2021-07-09
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
猜你喜欢
  • 2022-01-12
  • 2021-04-10
  • 2022-12-23
  • 2021-08-04
  • 2021-11-09
  • 2022-02-18
相关资源
相似解决方案