Write it at the front

Use MySQL In the process of , There's a problem : Look at the error log 、 Slow query log time , Time is always out of line with local time , The poor 8 Hours , This analysis is relatively troublesome .

New improvements

For the convenience of not knowing what causes the log time difference , And users who don't know how to solve it ,MySQL stay 5.7.2 A new parameter has been added to the version ——log_timestamps, To solve this problem .

Take a look at what the official file says :

This variable was added in MySQL 5.7.2. Before 5.7.2, timestamps in log messages were written using the local system time zone by default, not UTC. If you want the previous log message time zone default, set log_timestamps=SYSTEM.

log_timestamps This parameter is mainly for controlling error log、slow_log、genera log, And so on, the display time parameter of the log , But it doesn't affect general log and slow log Write to the table (mysql.general_log, mysql.slow_log) Show time in . When querying rows , have access to CONVERT_TZ() function , Or set system variables at the session level time_zone To convert to the desired time zone .

This parameter is globally valid , The values that can be set are :UTC and SYSTEM, By default UTC. It also supports dynamic settings , But I suggest you write in the configuration file , In order to avoid unnecessary trouble after restart .

solve

Said so much , You should also know how to solve the above problem .

log_timestamps The default parameter is UTC The time zone , This will make the time recorded in the log slower than that in China 8 Hours , It is not convenient to view the log . It is amended as follows SYSTEM Can solve the problem .

mysql> SHOW GLOBAL VARIABLES LIKE 'log_timestamps';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| log_timestamps | UTC |
+----------------+--------+ mysql> SET GLOBAL log_timestamps = SYSTEM;
Query OK, 0 rows affected (0.00 sec) mysql> SHOW GLOBAL VARIABLES LIKE 'log_timestamps';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| log_timestamps | SYSTEM |
+----------------+--------+

Reference resources :https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_log_timestamps

MySQL 5.7 One of the intimate parameters log_timestamps More articles about

  1. MySQL 5.7 One of the intimate parameters binlog_row_image

    I believe everyone knows mysql binlog The format of , There are three kinds of , Namely STATEMENT,MiXED,ROW. Each have advantages and disadvantages , For details, please refer to the information by yourself . stay MySQL 5.7 Version before , although ROW There are all kinds of good formats ...

  2. MySQL 5.7 Kengdai parameter – log_timestamps

    Original words on official website : This variable was added in MySQL 5.7.2. Before 5.7.2, timestamps in log messages were written ...

  3. paip. Lifting performance ---mysql performance Testing, and Parameter adjustment .txt

    paip. Lifting performance ---mysql performance Testing, and Parameter adjustment .txt author Attilax  Elon ,  EMAIL:1466519819@qq.com source :attilax The column Address :http://b ...

  4. Database related articles reprinted (1) MySQL Parameter configuration for performance optimization

    1. Purpose : According to the current status of the server , modify Mysql The system parameters of , To make rational use of the existing resources of the server , The most reasonable improvement MySQL performance . 2. Server parameters : 32G Memory .4 individual CPU, Every CPU 8 nucleus . 3.MySQL Objective ...

  5. MySQL Parameter configuration for performance optimization

    1. Purpose : According to the current status of the server , modify Mysql The system parameters of , To make rational use of the existing resources of the server , The most reasonable improvement MySQL performance . 2. Server parameters : 32G Memory .4 individual CPU, Every CPU 8 nucleus . 3.MySQL Objective ...

  6. MySQL Optimization II Cache parameter optimization

    The database belongs to IO Intensive applications , Its main responsibility is the management and storage of data . And we know that , The time to read a database from memory is microsecond level , And read a... From an ordinary hard disk IO It's at the millisecond level , There is a difference between the two 3 An order of magnitude . therefore , To optimize the number ...

  7. MySQL Medium sort_buffer_size Parameter size setting problem

    notice sort_buffer_size This parameter (connect Level parameters ,MySQL5.7, The default value is 1048576 byte , That is to say 1MB) The default value of is so small , I wonder if I can turn it up a little bit , Anyway, there are dozens of memories GB Of , ...

  8. mysql Command line parameters are explained

    mysql Command line parameters are explained http://blog.51yip.com/mysql/1056.html Usage: mysql [OPTIONS] [database]   // Command mode  -?, ...

  9. Mysql Parameter configuration for performance optimization ( turn )

    Preface : Mysql As an open source product widely used in database , We need to face different production pressures , Some performance problems can be solved by configuration optimization , Optimization can be divided into several directions :1. Optimize parameter configuration .2. Optimize database indexes .3. Optimize database structure , Such as Fen ...

Random recommendation

  1. Jian Jinxiang -SVN Version control scheme : Multi branch parallel development , Multi environment automatic deployment

    Both sides develop a product at the same time , At present, there are 3 An environment : Test environment . Pre release environment . Production environment . At present, the system deployment adopts jenkins Automated deployment tools use jenkins Deployment plan jenkins Test environment : Configured each branch of svn The earth ...

  2. from ZOJ2114(Transportation Network) To Link-cut-tree(LCT)

    [ A warm celebration ZOJ Return to ] [ First statement :LCT≠ Dynamic trees , The former is a data structure , The latter is a kind of problem , namely :LCT— solve —> Dynamic trees ] Link-cut-tree( Hereinafter collectively LCT) It's a powerful data structure , Not only can ...

  3. Scrum sprint The fourth day

    Catalog requirement Project links Burnout figure problem Today's mission Tomorrow's plan Member contribution Team meeting requirement What members have accomplished today ( If the completed task is a development or test task , The corresponding Github Code check in record screenshot : If the completed task is the key ...

  4. [CVPR2017] Deep Self-Taught Learning for Weakly Supervised Object Localization Paper notes

    http://openaccess.thecvf.com/content_cvpr_2017/papers/Jie_Deep_Self-Taught_Learning_CVPR_2017_paper. ...

  5. self-taught Python2.8- Conditions (if、if...else)

    self-taught Python The way self-taught Python2.8- Conditions (if.if...else) 1.if  Judgment statement if Sentences are used to make judgments , Its use format is as follows :  if The conditions to judge : When conditions are met , What to do When “ Judge ...

  6. Front end paging plug-in bootstrapPaginator Use

      introduce bootstrap-paginator.js <table class="table table-striped table-bordered table-hover dataT ...

  7. [Android]Eclipse install ADT[Android Development Tooling] Two solutions to failure

    reason Recently, I want to buy some new clothes Win7 Let's build it up in the library Android Development environment of , Although there are now Android Studio 了 , But I'm still used to it Eclipse One o'clock . Well known reasons ,Eclipse Direct installation AD ...

  8. Baidu AIG Knowledge mapping algorithm intern face by ( Have to take offer)

    one side : 1. Self introduction. 2. What programming language do you usually use python, In addition, I have learned C Language and JAVA 3.c How much memory does a pointer occupy in a language The answer is yes 8 Yes. , According to the machine, it should be 16 Bit or 32 position 4.python Inside map function , speak ...

  9. Spark And RDD convert to DataFrame Of Scala Realization

    rely on <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-sql_2. ...

  10. Compilation and installation nginx php swoole

    Before installing Prepare the environment  yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel then ...