异常信息:
java.sql.SQLException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support.
原因:
在MySQL 8.0 以上版本需要指明是否要进行SSL连接并更改时区,不然则报上面异常。
解决方案:
在数据库URL路径后面添加?useSSL=false&serverTimezone=UTC"
即可
分析:
1.MySQL在高版本需要指明是否要SSL连接,保证数据传输安全,不建议在没有服务器身份验证的情况下建立SSL连接。
2.UTC代表全球标准时间,中国使用的为东八区,早八个小时所以url的时区应使用中国标准时间
//北京时间东八区
serverTimezone=GMT%2B8
//上海时间
serverTimezone=Asia/Shanghai