How do I set the server timezone in the MariaDB configuration?
The only thing I can find in the documentation is using command-line flags, which I don't want to do.
default_time_zone
, which works on vanilla MySQL, isn't recognized by MariaDB.
It is default-time-zone
(-
instead of _
):
[server]
default-time-zone=+00:00
Here is a complete summary collecting from above question and answers:
open
/etc/my.cnf.d/server.conf
change to example:
#
# 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]
NOTE: for string
default-time-zone=-06:00 // this is equivalent to (america/edmonton)
You will need to figure out for your timezone to do so look up here https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Restart the mysql server:
service mariadb restart
Testing:
[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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With