新安裝的MySQL 5.7.27,發(fā)現(xiàn)error log、general log日志里面日志時(shí)間的時(shí)區(qū)不對(duì)。
error log
- 2019-09-11T12:53:23.988658Z 0 [Warning] CA certificate ca.pem is self signed.
- 2019-09-11T12:53:24.007777Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
- 2019-09-11T12:53:24.008117Z 0 [Note] IPv6 is avAIlable.
- 2019-09-11T12:53:24.008148Z 0 [Note] - '::' resolves to '::';
- 2019-09-11T12:53:24.008226Z 0 [Note] Server socket created on IP: '::'.
- 2019-09-11T12:53:24.088216Z 0 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.
- Version: '5.7.27-debug-log' socket: '/usr/local/mysql/tmp/mysql.sock' port: 3306 Source distribution
general log
- 2019-09-11T12:56:32.547294Z 2 Query show global variables like 'log_timestamps'
- 2019-09-11T13:01:04.907420Z 2 Query select DATABASE(), USER() limit 1
- 2019-09-11T13:01:04.908582Z 2 Query select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1
- 2019-09-11T13:01:04.908974Z 2 Statistics
原因:
mysql 5.7.2新增了參數(shù) log_timestamps,用于控制error log、general log、slow log日志記錄使用的時(shí)區(qū),只影響寫(xiě)入文件的時(shí)區(qū),不影響寫(xiě)入表中記錄的時(shí)區(qū)。默認(rèn)值是UTC,支持設(shè)置為SYSTEM使用系統(tǒng)的時(shí)區(qū)。
修復(fù):
1)執(zhí)行 set global log_timestamps=SYSTEM
執(zhí)行之后,新的日志的時(shí)區(qū)就會(huì)變成系統(tǒng)默認(rèn)的時(shí)區(qū)。
2)在my.cnf中添加 log_timestamps=SYSTEM