sourcecode

구성에 MariaDB 표준 시간대 설정

copyscript 2022. 10. 27. 22:30
반응형

구성에 MariaDB 표준 시간대 설정

MariaDB 설정에서 서버 타임존을 설정하려면 어떻게 해야 하나요?

설명서에서 찾을 수 있는 유일한 것은 명령줄 플래그를 사용하는 것입니다.이 작업은 하고 싶지 않습니다.

default_time_zonevanilla MySQL에서 동작하지만 MariaDB에서는 인식되지 않습니다.

그렇다.default-time-zone(-대신_):

[server]
default-time-zone=+00:00

패시의 생각은 옳았다.'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 // 이는 (미국/edmonton)에 해당합니다.

그러기 위해서는, 타임 존을 특정할 필요가 있기 때문에, https://en.wikipedia.org/wiki/List_of_tz_database_time_zones 를 참조해 주세요.

mysql 서버를 재시작합니다.

service 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)

언급URL : https://stackoverflow.com/questions/26349714/mariadb-set-timezone-in-config

반응형