全局参数system_time_zone
系统时区,在MySQL启动时会检查当前系统的时区并根据系统时区设置全局参数system_time_zone的值。html
The system time zone. When the server starts, it attempts to determine the time zone of the host machine automatically and uses it to set thesystem_time_zone
system variable. The value does not change thereafter.mysql
全局参数time_zonesql
用来设置每一个链接会话的时区,默认为system时,使用全局参数system_time_zone的值。数据库
The current time zone. This variable is used to initialize the time zone for each client that connects. By default, the initial value of this is 'SYSTEM' (which means, “use the value of system_time_zone”).this
参数log_timestamps
用于设置Error Log/Genaral Log/Slow Log这三种日志的时间信息。
有效值为UTC(默认)和SYSTEM(本地系统时区),当设置为system时,会使用参数system_time_zone的值。spa
修改参数time_zone操作系统
# 启动命令 --default-time-zone=timezone # 配置文件 default-time-zone=timezone # 运行期间 set global time_zone = timezone set global time_zone='+8:00' set global time_zone='Asia/Shanghai'
查看操做系统时区日志
## 使用date命令 date +"%Z %z" date -R ## 使用timedatectl timedatectl|grep "Timezone" ## 查看文件 /etc/timezone cat /etc/timezone
若是没法修改操做系统时区,又但愿数据库使用其余时区,则能够使用参数time_zone来修改。code