
05-服务器时区
如何分区当前环境是哪个时区?
window
shell
systeminfo | findstr "时区"mac
shell
ls -la /etc/localtimeLinux
shell
ls -la /etc/localtimemysql查询时区
mysql有独立的时区设置,MySQL 不会自动使用系统时区:
sql
-- 查看当前时区设置
SELECT @@global.time_zone, @@session.time_zone;
-- 查看当前时间
SELECT NOW(), UTC_TIMESTAMP();
-- 设置时区(需要权限)
SET GLOBAL time_zone = '+08:00';
SET time_zone = '+08:00';或者在 my.cnf 中配置:
shell
[mysqld]
default-time-zone = '+08:00'
