一、MySQL数据库设置默认时区

打开CMD

将工作目录切换到MySQL的bin下
cd  F:\mysql-5.7.21-winx64\bin

mysql -u root -p

输入密码即可登陆MySQL



select now();                      查看mysql系统时间。和当前时间做对比
 
set global time_zone = '+8:00';    设置时区更改为东八区

flush privileges;                  刷新权限

如果不设置默认时区,会出现以下异常:

Caused by: 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)