问题描述:
MySQL升级到8.0.11之后连接数据库报错:
Your login attempt was not successful, try again.
Reason: 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';