Showing the wrong time in GLPI App

What type of hardware are you using: Old laptop or computer
What YunoHost version are you running: 12.0.17
What app is this about: GLPI

Describe your issue

Hello!

I sucessfully installed GLPI on Yunohost but the time shown (e.g. creation time of a ticket) is wrong by minus 2 hours. The time on the host is correct (e.g. Wed Jul 23 10:29:32 AM CEST 2025). I can set a timezone in the GLPI settings (Setup > General > Timezone) but I have to first “activate” this option by running a php command in the GLPI installation. But I don’t have the necessary rights for the command:

Command to run: php bin/console database:enable_timezones

yunoadmin@yunohost$ sudo yunohost app shell glpi
glpi@yunohost$ php bin/console database:enable_timezones
Timezones usage cannot be activated due to following errors:
 - Access to timezone database (mysql) is not allowed.

I have also tried to run the command with sudo but I don’t know the passwort for the glpi user. I tried the yunohost admin password and the standard password for the GLPI Frontend.

So I guess my question is: How can I run commands as root in app (shells/containers))? Or is there an alternative to fixing the time error?

Cheers
scgeist

Share relevant logs or error messages

yunoadmin@yunohost$ sudo yunohost app shell glpi
glpi@yunohost$ php bin/console database:enable_timezones
Timezones usage cannot be activated due to following errors:
 - Access to timezone database (mysql) is not allowed.

Try :

sudo mysql
# Once in the MariaDB shell:
GRANT SELECT ON mysql.time_zone_name TO 'glpi'@'localhost';

(CTRL+D to exit)

Thanks! This helps but brings me to the next error.

yunoadmin@yunohost:~$ sudo yunohost app shell glpi
glpi@yunohost:~$ php bin/console database:enable_timezones
Timezones usage cannot be activated due to following errors:
 - Timezones seems not loaded, see https://glpi-install.readthedocs.io/en/latest/timezones.html.

To fix it I need to run another command and I run into the same problem regarding missing credentials.

Command to run: mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -p -u root mysql

The output of the command seem to be SQL Statements.

First few lines of output:

set @wsrep_is_on=(select coalesce(sum(SESSION_VALUE='ON'), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_on');
SET STATEMENT SQL_MODE='' FOR SELECT concat('%', GROUP_CONCAT(OPTION ORDER BY OPTION DESC), '%') INTO @replicate_opt  FROM   (SELECT DISTINCT concat('REPLICATE_', UPPER(ENGINE)) AS OPTION    FROM information_schema.TABLES    WHERE TABLE_SCHEMA=DATABASE()      AND TABLE_NAME IN ('time_zone',                         'time_zone_name',                         'time_zone_transition',                         'time_zone_transition_type',                         'time_zone_leap_second')      AND ENGINE in ('MyISAM',                     'Aria')) AS o;
set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select coalesce(sum(GLOBAL_VALUE NOT LIKE @replicate_opt), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_mode');
execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone''', 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone ENGINE=InnoDB', 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_name''', 'do 0');

So since I can enter MariaDB via sudo mysql can I source the output into the GLPI DB like so?

yunoadmin@yunohost:~$ sudo mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4048
Server version: 10.11.11-MariaDB-0+deb12u1 Debian 12
MariaDB [(none)]> use glpi
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [glpi]> source /home/yunoadmin/timzoneinfo.sql

Or will I destroy GLPI this way? :face_with_peeking_eye:

Thanks for your help!

Let’s not try that. :stuck_out_tongue:

The root user does not need to log in the database:

sudo su
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -D mysql

You may then try again the GLPI command, I tried this with success on my test server:

yunohost app shell glpi
php bin/console database:enable_timezones
Timezone usage has been enabled.

This was the last puzzle piece. It works now! Thanks for your help :slight_smile:

I documented all steps here for convenience:

Goal

Activate timezones in GLPI to show correct time

Problem

Not enough rights in DB to activate timezones in DB

yunoadmin@yunohost$ sudo yunohost app shell glpi
glpi@yunohost$ php bin/console database:enable_timezones
Timezones usage cannot be activated due to following errors:
 - Access to timezone database (mysql) is not allowed.

Solution

Change to root

sudo su

Import timezone into DB

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -D mysql

Give rights in DB to glpi user

GRANT SELECT ON mysql.time_zone_name TO 'glpi'@'localhost';

Change to GLPI shell in Yunohost and activate timezones in DB

yunohost app shell glpi
glpi@yunohost:~$ php bin/console database:enable_timezones

Migrate deprecated datetime format (if necessary. see error message)

Error message:

1 columns are using the deprecated datetime storage field type.

Command to migrate:

glpi@yunohost:~$ php bin/console migration:timestamps

Check if timezones are activated in GLPI

On GLPI Frontend:
Setup -> General -> Default ValuesTimezone

Success!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.