今天碰到一坑,特此記錄
環境springboot2 mysql-connector-java 8.0.15鏈接mysql5.6
出現問題:java
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) ~[mysql-connector-java-8.0.15.jar:8.0.15]
連接url:mysql
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false
代碼在其餘機器上測試過的,肯定是mysql版本引發的,搜了一下,各類各樣的問題,最終都沒有解決。spring
測試過程當中發現加入了sql
&serverTimezone=GMT%2B8
即完整url:
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8
問題解決springboot