The company has developed a database middleware system, which found that writing to datetime or timestamp fields occurs 8 hours longer than real time.
After the investigation, found that it is mysqldump to get a ghost
Because we are using the Maya maintenance long connection, and the long connection is reused, when the mysqldump is executed, mysqldump the--TZ-UTC parameter is enabled by default, and the time zone for this connection is set to the UTC time zone (while the timezone in Beijing is +08:00), Then a business using this database connection, will appear datetime/timestamp time + 8 hours.
Official Document Explanation:
--tz-utc
This option enables TIMESTAMP columns to is dumped and reloaded between servers in different. mysqldump sets its connection time zone to UTC and adds SET time_zone= ' +00:00 ' to the dump file. Without this option, TIMESTAMP columns are dumped and reloaded in the ' time zones ' to the ' source and destination serve RS, which can cause the values to change if the servers are in different time zones. --TZ-UTC also protects against changes due to daylight time. --TZ-UTC is enabled by default. To disable it, use--SKIP-TZ-UTC. This option is added in MySQL 5.1.2.