MySQL registra tempo diferente de NOW ()

2

O servidor MySQL registra entradas com horário diferente do sistema ou do próprio mysql:

mysql> select @@global.time_zone;
+--------------------+
| @@global.time_zone |
+--------------------+
| SYSTEM             |
+--------------------+
mysql> select NOW();
+---------------------+
| NOW()               |
+---------------------+
| 2016-02-24 10:47:30 |
+---------------------+

# /var/log/mysql/mysql_queries.log
2016-02-24T18:47:11.191126Z    2 Connect        root@localhost on  using Socket
2016-02-24T18:47:11.191421Z    2 Query  select @@version_comment limit 1
2016-02-24T18:47:16.769493Z    2 Query  select @@global.time_zone
2016-02-24T18:47:30.503214Z    2 Query  select NOW()

O registro de data e hora parece sincronizado com o log:

mysql> show variables;
timestamp               | 1456339753.062182 # 18:47
log_timestamps          | UTC
    
por aaaaaa 24.02.2016 / 19:56

1 resposta

7

A solução foi super simples: examine as variáveis e tente localizar as relevantes:

log_timestamps                   | UTC

Então eu mudei para 'SYSTEM':

mysql> SET GLOBAL  log_timestamps  = 'SYSTEM';

# /var/log/mysql/mysql_queries.log
2016-02-24T18:54:23.837289Z    2 Query  SET GLOBAL  log_timestamps  = 'SYSTEM'
2016-02-24T10:54:25.949232-08:00    2 Query     show variables

O tempo no registro alternou de 18:54 a 10:54 como deveria.

De documentos do MySQL :

  • log_timestamps

This variable controls the timestamp time zone of error log messages, and of general query log and slow query log messages written to files. It does not affect the time zone of general query log and slow query log messages written to tables (mysql.general_log, mysql.slow_log). Rows retrieved from those tables can be converted from the local system time zone to any desired time zone with CONVERT_TZ() or by setting the session time_zone system variable.

    
por 24.02.2016 / 19:59