Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setting MariaDB time zone to UTC on macOS

Setting Time Zone of MariaDB to UTC

  1. If you are logged in then exit mariadb and stop it via: brew services stop mariadb
  2. To populate time zone tables: To load the time zone tables from the command line, pass the zoneinfo directory path name to mysql_tzinfo_to_sql and send the output into the mysql program. If your root user has no password drop -p from below command:
    mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
    
  3. Open my.cnf (/usr/local/etc) and add following lines to it:
    [mysqld]
    default_time_zone='UTC'
    
  4. Restart Database: brew services restart mariadb
  5. Login to database and check whether time zone tables are populated or not. If they are not the count below will be 0:
    SELECT COUNT(*) FROM mysql.time_zone_name;
    +----------+
    | COUNT(*) |
    +----------+
    |      594 |
    +----------+
    
  6. Check the time zone:
    MariaDB [(none)]> SELECT @@time_zone;
    +-------------+
    | @@time_zone |
    +-------------+
    | UTC         |
    +-------------+
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.