1、Mysql报错
HikariPool-1 - Exception during pool initialization.com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure。
2、报错原因
Mysql报错原因是MySql版本问题,在Mysql5.5以上的版本,创建连接会报此错误。
1 Establishing SSL connection without server's identity verification is not recommended.
2 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.
3 For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'.
4 You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
5
6 翻译:不建议在没有服务器身份验证的情况下建立SSL连接。
7 根据MySQL 5.5.45+、5.6.26+和5.76+的要求,如果不设置显式选项,则必须在默认情况下建立SSL连接。
8 为了遵守不使用SSL的现有应用程序,verifyserver证书属性被设置为“false”。
9 您需要通过设置useSSL=false来显式禁用SSL,或者设置useSSL=true,并为服务器证书验证提供信任存储。
mysql官网说明:https://dev.mysql.com/doc/connectors/en/connector-j-connp-props-security.html

3、解决方法
在配置mysql的url的时候加上?useSSL=false来显式禁用 SSL,就可以解决这个启动服务报错的问题。
需要特别注意的是mysql的端口号,一定要可以telnet通,避免服务没有启动成功,或者因为防火墙的原因无法连接服务,检查mysql数据库的ip地址、端口号、账号密码,以及数据库是否都正常。
1 # 案例一 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/demo_db?useSSL=false
2
3 # 案例二 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/demo_db?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT+8&useSSL=false
4、注意事项
如果Mysql数据库已经升级到了Mysql8版本的话,Mysql的驱动一定要进行调整,否则也会导致莫名其妙的报错,
1 # Mysql 5.x驱动
2 spring.datasource.driver-class-name==com.mysql.jdbc.Driver
3
4 # Mysql 8.x驱动
5 spring.datasource.driver-class-name==com.mysql.cj.jdbc.Driver
6
7 <!-- mysql数据库驱动,maven坐标依赖 -->
8 <dependency>
9 <groupId>mysql</groupId>
10 <artifactId>mysql-connector-java</artifactId>
11 <!-- 此处的mysql 版本可以根据自己的数据库匹配 -->
12 <version>8.0.11</version>
13 </dependency>
吐槽时刻:时隔1181天【又3年2个月23天】,又更新了一条博客随笔,感慨万千,当年的热情激情已经变得麻木不仁,当年的毛头小伙子已经向着35岁年龄危机步步逼近,除了略感焦虑,作为一个普通人的我也只有逆风向前,为了养家糊口,为了生计,也只能向前看,向前走,加油,共勉!!!