MySQL时区设置错误(You must configure either the server or JDBC driver)

今天配置数据源时,出现以下错误:
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的时候时区设置的不正确 mysql默认的是美国的时区,而我们中国大陆要比他们迟8小时,采用+8:00格式

解决办法:

需要修改MySQL配置文件,在MySQl安装目录中找到my.ini或者.ini后缀文件

在[mysqld]节点下面加上

default-time-zone='+08:00'

然后需要重启MySQL服务

但是因为mysql版本的原因,我在cmd中输入net start mysql,显示服务名无效,于是就无法重启mysql

MySQL时区设置错误(You must configure either the server or JDBC driver)_第1张图片

其实还是版本的原因,输入net start mysql57就可以了

MySQL时区设置错误(You must configure either the server or JDBC driver)_第2张图片

此时我需要在cmd中登录mysql,但是这个时候输入mysql -uroot -p语句是无效的

此时需要打开计算机->属性->高级系统设置->高级->环境变量,找到path,编辑,在path后加英文分号,将mysql安装目录添加到后面    添加的目录:C:\Program Files\MySQL\MySQL Server 5.7\bin

然后输入mysql -uroot -p

MySQL时区设置错误(You must configure either the server or JDBC driver)_第3张图片

接着会提示输入密码,然后出现mysql>

此时直接输入set global time_zone='+8:00'还是不行

需要在set global time_zone='+8:00'语句后加分号作为结尾,

终于大功告成

你可能感兴趣的:(其他,框架学习)