如何将MySQL服务器时区设置为UTC?

时间:2014-05-09 17:22:30

标签: mysql

我已将此行default_time_zone='+00:00'添加到 /etc/my.cnf 中,但重启服务器时收到此错误消息:

error: Found option without preceding group in config file: /etc/my.cnf

更新

# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

default_time_zone = "+00:00"

# The following options will be passed to all MySQL clients
[client]
#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port            = 3306

1 个答案:

答案 0 :(得分:5)

将其从default_time_zone更改为default-time-zone=并将其放入cnf的[mysqld]部分