MySQL 8.0 连接报错 java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.
·
描述:MySQL安装在VMware上面的CentOS,在Windows访问,连不上,一是linux的防火墙没有开放端口,二是MySQL默认不支持外部链接,报错大概如下,或者是其他错误
java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.
或者
null, message from server: "Host '192.168.197.1' is not allowed to connect
- 如果是写Java访问的,因为使用的是MySQL 8.0 ,所以则要注意将版本进行修改
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
- 如果是用DBeaver或者navicat访问的,则要从linux进入MySQL里面,对一点小小的配置进行修改
update user set host = '%' where user = 'root';
因为MySQL默认不对外开放,所以root的host会写死在localhost,改为%
是通配符的含义,所以外界就可以访问了,可以去MySQL里面的mysql数据库,user表查看
use mysql;
select * from user where user='root';
Host|User
----|----
% |root
更多推荐
所有评论(0)