今天在创建springSSM项目时显示连接数据库失败,报错信息如下:
Tue Apr 16 14:22:41 GMT+08:00 2024 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.
原因是:在建立到MySQL服务器的SSL连接时,没有验证服务器的身份。从MySQL 5.5.45+、5.6.26+和5.7.6+版本开始,如果没有明确设置相关选项,默认情况下必须建立SSL连接。
SSL 的英文全称是 “Secure Sockets Layer” ,中文名为 “ 安全套接层协议层 ”。SSL是在Web服务器和Web客户机之间建立经过身份验证和加密会话的Web协议。
发现是url的问题,可以在url后面加上?SSL=false,禁用SSL连接来解决这个问题
但会出现中文乱码的问题,可以使用下面完整的url路径
jdbc:mysql://localhost:3306/your_database?useSSL=false&serverTimezone=GMT&useUnicode=true&&characterEncoding=utf-8&&serverTimezone=UTC&