【发布时间】:2014-12-08 14:12:29
【问题描述】:
如何在 MariaDB 配置中设置服务器时区?
我在文档中唯一能找到的是使用命令行标志,我不想这样做。
default_time_zone,在原版 MySQL 上工作,无法被 MariaDB 识别。
【问题讨论】:
如何在 MariaDB 配置中设置服务器时区?
我在文档中唯一能找到的是使用命令行标志,我不想这样做。
default_time_zone,在原版 MySQL 上工作,无法被 MariaDB 识别。
【问题讨论】:
是default-time-zone(- 而不是_):
[server]
default-time-zone=+00:00
【讨论】:
sudo systemctl start mariadb 我收到以下消息:Job for mariadb.service failed. See 'systemctl status mariadb.service' and 'journalctl -xn' for details.
Pasi 的想法是正确的。 'UTC' 不起作用,但 '+00:00' 起作用。
【讨论】:
以下是从上述问题和答案中收集的完整摘要:
打开
/etc/my.cnf.d/server.conf
换个例子:
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
default-time-zone=-06:00
# this is only for the mysqld standalone daemon
[mysqld]
注意:对于字符串
default-time-zone=-06:00 // 这相当于 (america/edmonton)
您需要确定您的时区,请查看此处https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
重启mysql服务器:
服务 mariadb 重启
测试:
[smith@home my.cnf.d]# mysql -u smith -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.2.31-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT now();
+---------------------+
| now() |
+---------------------+
| 2020-04-22 11:19:38 |
+---------------------+
1 row in set (0.01 sec)
【讨论】: