Date timezone error a valid timezone that matches mysql and the system

Moderators: Developers, Moderators

Moderators: Developers, Moderators

sendil

Posts: 1
Joined: Mon Apr 19, 2021 1:57 am

Error «A valid timezone that matches Mysql and the system»

I get the same error upon installing Cacti v1.2.16 on both Ubuntu 20.04.02 LTS as well as Centos 8 Stream .

date.timezone Error «A valid timezone that matches Mysql and the system

Checked the date and time Configuration on both mysql, PHP and system and they are OK .

Is it a bug if not help me on this.

Regards,
Sendil kumar

Attachments
Screenshot from 2021-04-20 10-53-11.png
Screenshot from 2021-04-20 10-53-11.png (231.41 KiB) Viewed 10966 times

netniV

Cacti Guru User
Posts: 3433
Joined: Sun Aug 27, 2017 12:05 am

jackouille

Posts: 44
Joined: Thu Apr 26, 2012 7:41 am

Re: Error «A valid timezone that matches Mysql and the system»

Post

by jackouille » Tue Jul 19, 2022 3:35 pm

Hi,

I perform a new install of Cacti on Rocky 8 and I’m facing the same issue despite all values seems to be right:
MariaDB [(none)]> SELECT @@GLOBAL.time_zone, @@SESSION.time_zone;
+———————+———————+
| @@GLOBAL.time_zone | @@SESSION.time_zone |
+———————+———————+
| Europe/Zurich | Europe/Zurich |
+———————+———————+
1 row in set (0.000 sec)

MariaDB [(none)]> quit;
Bye
[[email protected] ~]# timedatectl
Local time: Tue 2022-07-19 22:30:25 CEST
Universal time: Tue 2022-07-19 20:30:25 UTC
RTC time: Tue 2022-07-19 20:30:25
Time zone: Europe/Zurich (CEST, +0200)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
[[email protected] ~]# grep ezone /etc/php.ini
; Defines the default timezone used by the date functions
; https://php.net/date.timezone
date.timezone = Europe/Zurich
;date.timezone = CET

PHP Recommendations
version 8.1.8 >= 5.4.0 Passed PHP 5.4.0 is the mimimum version
memory_limit 2048M >= 400M Passed A minimum of 400M memory limit
max_execution_time 60 >= 60 Passed A minimum of 60 m execution time
date.timezone >= Error A valid timezone that matches MySQL and the system

And of course server was rebooted, any hint ?

Who is online

Users browsing this forum: No registered users and 1 guest

Summary:

ERROR: Your MySQL TimeZone database is not populated.
Please populate this database before proceeding.

Problem or Goal:

I ran into this error while doing pre-installation checks for cacti installation on CentOS 8

Cause:

MySQL TimeZone database is not populated

Solution:

1. Make sure to first set the proper date and timezone on your server, to do this run the following commands:
//The command below lists all the valid timezones on your server
# timedatectl list-timezones

// The command below, sets the preferred timezone on your server
# timedatectl set-timezone Africa/Kampala

// You can use the «date» command to check and verify that the proper date and timezone have been set.

2. Edit /etc/php.ini file with the suggested setting showing in the installation script, this includes setting the timezone.
Note: (Make sure this line is not commented out «date.timezone», as it will be commented out by default, remember to un-comment it, otherwise it will generate for you another error like «date.timezone >= Error A valid timezone that matches MySQL and the system»)

memory_limit = 800M
max_execution_time = 60
date.timezone = Africa/Kampala

3. Populate TimeZone table in MySQL database with the global TimeZone information, to achive this, run the following command, supply the root mysql password when prompted and hit enter.

# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

// You can use the command below to verify that the timzone information has been updated in your database.

# mysql -u root -p
Enter password:
mysql> use mysql;
mysql> show variables like ‘%time_zone%’;

4. Now you need to grant access to the MySQL TimeZone database for user Cacti, 
so that the database is populated with global TimeZone information, to do this run the following commands.

# mysql -u root -p
Enter password:
mysql> use mysql;
mysql> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost;
mysql> flush privileges;

5. Restart services; 

systemctl restart php-fpm.service
systemctl restart mariadb.service
systemctl restart httpd.service

Note: in some cases, it the error doesn’t clear in the cacti installation script, you will need to restart the server to clear the system cache

Problem Solved?

Yes, i was able to continue through the cacti installation script and successfully deploy cacti on CentOS 8

Hello everyone !

When installing  some of the new versions of cacti you may come across these below 2 PHP errors related to a timezone which will prevent you from installation CACTI

This is a simple fix that involves editing the php.ini for PHP and php.ini file for PHP CLI

cacti installation screen

the PHP.ini files are located in these 3 directories on a Debian based system

/etc/php/7.0/fpm/php.ini
/etc/php/7.0/cli/php.ini
/etc/php/7.0/apache2/php.ini

if you are having a hard time finding your php.ini files run the following command to search for them

find / -name php.ini

Now once you have located the files we need to add the timezone to them to fix this error

see the below example on the php.ini file for apache

[email protected]:~# cat /etc/php/7.0/apache2/php.ini | grep timezone
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
[email protected]:~#

we will need to uncomment the date.timezone directive and add our timezone in my case it’s America/Toronto

you can find a list of all supported PHP timezones here http://php.net/manual/en/timezones.php

using your choice of text editor edit /etc/php/7.0/apache2/php.ini  to below
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = “America/Toronto”

After you finish editing the file you must restart the apache process either by ( service apache2 restart) or on systemd systems ( systemctl apache2 restart)

[email protected]:~# service apache2 restart
[email protected]:~# service apache2 status
● apache2.service – LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf

Now let’s check the installer  to see if the error has cleared

cacti installtion screen

As you can see the error changed to Passed and the timezone matches what I set it to in php.ini

now all you have to do is the same steps for  /etc/php/7.0/cli/php.ini

Hope this helps!

Liked it? Take a second to support Sean Mancini on Patreon!

krizzle

Posts: 19
Joined: Tue Oct 30, 2018 6:07 pm

mysql’s timezone does not match the system timezone!

Hello,
I recently installed Zoneminder 1.36.14 onto Ubuntu Server 20.04. I followed IConnors video here — https://www.youtube.com/watch?v=RhBsW8HkOG4
After the install I noticed that the timestamp on the videos and the time recorded in the event lists were incorrect. I used

Code: Select all

sudo timedatectl set-timezone <your_time_zone>

to configure the timezone to my location. After doing so the timestamp was correct but the times within the event list were still in UTC time. The log also showed an alert which read «ZoneMinder is not configured properly: mysql’s timezone does not match the system timezone! Event lists will display incorrect times.» Can anyone help me configure the timezone within mysql so the times match within my setup? Any help is appreciated.

Thanks.

bbunge

Posts: 2872
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: mysql’s timezone does not match the system timezone!

Post

by bbunge » Wed Apr 13, 2022 11:14 pm

That wonderful YouTube video aside there are easier install instructions in the ZM WIKI here: https://wiki.zoneminder.com/Ubuntu_Serv … der_1.36.x

AS for the timezone issue, your time is likely coming from the php.ini. There is a setting in there to change the timezone but you can also set it in Zoneminder Options — System — Timezone.

Or:
Add timezone to PHP

nano /etc/php/7.X/apache2/php.ini (Note: replace 7.X with your version of PHP)

Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone

[Date]

Defines the default timezone used by the date functions
http://php.net/date.timezone

date.timezone = America/New_York

Magic919

Posts: 1176
Joined: Wed Sep 18, 2013 6:56 am

Re: mysql’s timezone does not match the system timezone!

Post

by Magic919 » Thu Apr 14, 2022 7:28 am

MySQL will follow the system TZ unless you specify otherwise. Make sufre you restart the DB after you set the system TZ.

————————————————————————
I’m nothing to do with ZM, ZMNinja or ZMES, I just use them.
Contribute funding to the devs here or ZM dies — https://github.com/sponsors/connortechnology

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Datakom dkg 116 ошибки
  • Configuration file parse error
  • Copperbeard sea of thieves ошибка
  • Dataformat error we reached the end of the buffer
  • Conan exiles вы слишком далеко от создателя сервера как исправить

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии