安装连接mysql8时候遇到的问题以及解决(转)

官网下载mysql8的安装包:

https://dev.mysql.com/downloads/

下一步安装即可。

mysql8增加了传说中的安全性校验

遇到的几个问题:

1、natcat连接不上。参考链接:https://blog.csdn.net/weixin_42181147/article/details/80360151

必须执行下面两个步骤,缺一不可。

一、        mysql8.0加密方式与mysql5几加密方式不同,需要先更改加密方式。

1.   更改加密方式

ALTERUSER 'root'@'localhost' IDENTIFIED BY 'password' [a1] PASSWORDEXPIRE NEVER;

2.   更改密码

ALTERUSER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';[a2] 

 [a1]你的root用户密码

 [a2]你的root用户密码

二、        修改root权限。可解决navicat连接mysql时报1130错误。

1.修改user表中root的权限:Update user set host = ‘%’ whereuser = ‘root’;

2.在查看user表:select user,host from user;

3.更新表:flushprivileges;

也可以在mysql安装的时候安全性选择上选mysql5的特征

然后idea配置mybatis-generator的配置

发现mysql8的驱动改了,变为:

com.mysql.cj.jdbc.Driver
执行报错,什么ssl链接方式的警告,解决方式:
jdbc:mysql://localhost:3306/testweb?useSSL=false
加参数指定一下。

然后有报时区不一致啥问题。参考链接:https://blog.csdn.net/weixin_41908757/article/details/80283015
1、错误原因:
使用原mysql5.1.38不会出现该问题
因使用了Mysql最新版驱动所以报错

2、解决方案:
方案1、在项目代码-数据库连接URL后,加上 (注意大小写必须一致)
?serverTimezone=UTC


方案2、在mysql中设置时区,默认为SYSTEM
set global time_zone='+8:00'


Sun Mar 19 20:51:50 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

从警告信息中可以看出,5.5.45+、5.6.26+ 和 5.7.6+ 版本默认 SSL 连接,除非特别指定不需要 SSL 连接,最好在 JDBC URL 中指明连接方式:

String jdbcUrl = "jdbc:mysql:///test?useSSL=false";
文章标签:  mysql jdbc ssl
个人分类:  JDBC MySQL
 

 
上海市辖区27岁刘某辞去快递工作,刷出惊人存款曝光!汇好 · 顶新
禁止偷窥!这望远镜可望10公里!微光夜视可拍照!珐苏 · 顶新

个人资料

原创
118
粉丝
8
喜欢
4
评论
6
等级:
 
访问:
 
8万+
积分:
 
1892
排名:
 
2万+
勋章:
 

猜你喜欢

转载自www.cnblogs.com/aigeileshei/p/9076137.html