mysqltimestampbinlog

How to understand the timestamp in the mysql binlog?


the binlog always looks like this:

#140105 18:49:33 server id 2  end_log_pos 354   Query   thread_id=1     exec_time=0     error_code=0
SET TIMESTAMP=1388918973/*!*/;
/* some SQL statement */
/*!*/;

The illustration from the official site is :

In the first line, the number following at indicates the starting position of the event in the binary log file.

The second line starts with a date and time indicating when the statement started on the server where the event originated. For replication, this timestamp is propagated to slave servers. server id is the server_id value of the server where the event originated. end_log_pos indicates where the next event starts (that is, it is the end position of the current event + 1). thread_id indicates which thread executed the event. exec_time is the time spent executing the event, on a master server. On a slave, it is the difference of the end execution time on the slave minus the beginning execution time on the master. The difference serves as an indicator of how much replication lags behind the master. error_code indicates the result from executing the event. Zero means that no error occurred.

It said "The second line starts with a date and time", it seemed this format of datetime is quite different from the "SET TIMESTAMP" clause, where the number means the seconds from 1970-1-1, but what is the "#140105 18:49:33" means, that's date of that?


Solution

  • 140105 means YYMMDD.

    05 JAN(01) 2014

    obviously 18:49:33 is the time