MySQL Problem-timezone

Source: Internet
Author: User

Background operations My colleague asked me that some of my colleagues actually clocked in a different time than the database clock-in time.


Mysql> select *,from_unixtime (create_time)  from  table name  where source_id=xxx\g*****  1. row ***************************                         id : xxx                        uid: xxx                  source_id: xxx                create_time: 1495324892                       type:  0                   source_status: 0                 nick_ name:  Environmental Monitoring Group-xxx                 start_time: 1495324883                     remark:  Ignore video            pre_check_status: 0                     source: 3from_unixtime (create_time):  2017-05-21 00:01:321 row in set  (0.00 SEC)

Because the operation of the library is 2 Master 2 from, I compared the master-slave data, found that really different, one is 8 in the morning, the other is the wee hours, using the From_unixtime function, the results of a 8-hour difference, more like a time zone problem

Mysql> Select From_unixtime (1495324892); +---------------------------+| From_unixtime (1495324892) |+---------------------------+| 2017-05-21 08:01:32 |+---------------------------+1 row in Set (0.00 sec) mysql> Select From_unixtime (1495324892); +---------------------------+| From_unixtime (1495324892) |+---------------------------+| 2017-05-21 00:01:32 |+---------------------------+1 row in Set (0.00 sec)

Suspect is a time zone problem for Linux machines, but query discovery is the same

Thu 15:11:29 CST 2017

Since it is not relevant to the Linux time zone, it should be related to the time of MySQL, and then query the master and slave time separately.

Mysql> Select Now (); +---------------------+| Now () |+---------------------+| 2017-05-25 15:12:28 |+---------------------+1 row in Set (0.00 sec) mysql> Select Now (); +---------------------+| Now () |+---------------------+| 2017-05-25 07:09:31 |+---------------------+1 row in Set (0.00 sec)

It's a matter of time for MySQL.

Mysql> Show variables like "%time_zone%", +------------------+--------+| variable_name | Value |+------------------+--------+| System_time_zone | HKT | | Time_zone | SYSTEM |+------------------+--------+2 rows in Set (0.00 sec) mysql> Show variables like "%time_zone%"; +-------------- ----+--------+| variable_name | Value |+------------------+--------+| System_time_zone | UTC | | Time_zone | SYSTEM |+------------------+--------+2 rows in Set (0.00 sec)

Found a MySQL in UTC time, world standard Time, while the other is Hong Kong time, China is the East eight, more than the world standard time more than 8 hours, which explains why the 8-point clock, but shows in the early hours of work. So put the problematic MySQL, re-modify the time zone

Set global Time_zone = ' time_zone '; set = ' ""; flush privileges;





This article is from the DBA OPS space blog, so be sure to keep this source http://dadaman.blog.51cto.com/11373912/1929429

MySQL Problem-timezone

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.