[FAIL] Time between this server and the mysql database is off

Hello,

I’ve just complete my first install on LibreNMS as I’ve heard so many good things about it. I’m just stuck on the time issue where my MYSQL database seems to be wrong, how do I fix this?

[[email protected] librenms]# ./validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.54-5-g267e07e
DB Schema | 2019_07_03_132417_create_mpls_saps_table (139)
PHP       | 7.2.19
MySQL     | 5.5.60-MariaDB
RRDTool   | 1.4.8
SNMP      | NET-SNMP 5.7.2
====================================

[OK]    Composer Version: 1.8.6
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[FAIL]  Time between this server and the mysql database is off
 Mysql time 2019-07-31 14:57:15
 PHP time 2019-07-31 22:57:15

[OK]    Database schema correct
[WARN]  You have not added any devices yet.
        [FIX]:
        You can add a device in the webui or with ./addhost.php
[WARN]  Your local git contains modified files, this could prevent automatic updates.
        [FIX]:
        You can fix this with ./scripts/github-remove
        Modified Files:
         bootstrap/cache/.gitignore
         logs/.gitignore
         rrd/.gitignore
         storage/app/.gitignore
         storage/app/public/.gitignore
         storage/debugbar/.gitignore
         storage/framework/cache/.gitignore
         storage/framework/cache/data/.gitignore
         storage/framework/sessions/.gitignore
         storage/framework/testing/.gitignore
         storage/framework/views/.gitignore
         storage/logs/.gitignore

Thanks

mysql DB is set by your local system time.

You should change your MySQL timezone to UTC, because I’ve heard that PHP7 having trouble with timezone that doesn’t support local time. I’ve experienced like this. PHP7 keep with UTC, while MySQL succeed changed into local time.

and thats why in the installs docs says:

Configure PHP

Ensure date.timezone is set in php.ini to your preferred time zone. See http://php.net/manual/en/timezones.php for a list of supported timezones. Valid examples are: "America/New_York", "Australia/Brisbane", "Etc/UTC".

I’ve set it in both cli and fpm php.ini, but, it still didn’t changed. So, the solution of mine is change timezone of MySQL to UTC

ok… never had that problem, so i dont know your installation, but php = php
or you changed it whit the quotes, what is not used normaly

45%20PM

I’ve tried it with and without quotes. It still UTC in PHP. So, what should I do to change it into local system time?

and what does your phpinfo(); says? (maybe other overruling ini file?)

I guess run through this?
https://stackoverflow.com/questions/930900/how-do-i-set-the-time-zone-of-mysql

Pssst, here is an easy change, just dont forget to use your PHP version and Timezone ofcourse

This works for Ubuntu 18 and 19

sudo sed -i "s,;date.timezone =,date.timezone = \"Europe/Amsterdam\",g" /etc/php/7.2/apache2/php.ini
sudo sed -i "s,;date.timezone =,date.timezone = \"Europe/Amsterdam\",g" /etc/php/7.2/cli/php.ini

sudo timedatectl set-timezone Europe/Amsterdam
sudo dpkg-reconfigure -f noninteractive tzdata

sudo mysql -uroot --execute="SET GLOBAL time_zone = 'Europe/Amsterdam';"

sudo systemctl restart apache2
sudo systemctl restart mysql

This will change your timezone on your OS, PHP and MySQL to your timezone.