背景:
把mysql-connector-java升级到了8.0.11,导致查询数据库时候出现了错误
错误信息:
Could not get JDBC Connection; nested exception is 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.
原因:
没有明确时区
解决方案:
方式一:修改数据库url
jdbc:mysql://localhost:3306/springsecurity?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
方式二:修改数据库时区
mysql -hlocalhost -uroot -p show variables like '%time_zone%' set global time_zone='+8:00';