干货分享-关于mysql报错,常见错误集合,看看你们有没有遇到过?

干货分享-关于mysql报错,常见错误集合,看看你们有没有遇到过?_第1张图片
项目连接mysql数据库出现

Unknown system variable ‘tx_isolation’

数据库驱动jdbc版本太低。(我用的是mysql8.0.18)
解决办法:换高版本的数据库驱动


干货分享-关于mysql报错,常见错误集合,看看你们有没有遇到过?_第2张图片

Cannot resolve com.mysq.jdbc.Connection.ping method. Will use ‘SELECT 1’ instead.

是由于mysql与druid版本不兼容所导致的,这里分享一下我用的mysql8.0.11或18
druid1.0.10(试验了很长时间才找到)


java.sql.SQLException: The server time zone value ‘�й���׼ʱ��’

在spring.datasource.url=jdbc:mysql://localhost:3306/manger_system?characterEncoding=UTF-8的后面增加
&serverTimezone=Asia/Shanghai


mysql 无法连接 Unable to load authentication plugin ‘caching_sha2_password’.

mysql8之前的版本使用的密码加密规则是mysql_native_password,但是在mysql8则是caching_sha2_password,所以需要修改密码加密规则。
解决:使用命令行登录mysql
然后输入use mysql 和 select user,host,plugin,authentication_string from user;
干货分享-关于mysql报错,常见错误集合,看看你们有没有遇到过?_第3张图片
输入alter user ‘root’ @‘localhost’ identified with mysql_native_password by ‘密码’;
进行更改


Public Key Retrieval is not allowed

在连接url上加 allowPublicKeyRetrieval=true


MySql 8.0及对应驱动包匹配注意点

以前:
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://xxx.xx.xx.xxx:3306/db?characterEncoding=utf-8
jdbc.username=root
jdbc.password=admin
现在:
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://xxx.xx.xx.xxx:3306/db?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
jdbc.username=root
jdbc.password=admin

你可能感兴趣的:(mysql)