mysql basis of log management (query logs, slow query log, error logs, binary logs, relay logs, transaction logs)

  Log file records all types of activities MySQL database, MySQL database log file has a common  query log, slow query log, error logs, binary logs, relay logs  , transaction logs .

  Want to make the configuration permanent need to write the contents of the configuration file: / etc / my.cnf.d / server.cnf

First, the query log

  Called query log in mysql general log (Common Log), a database query logging command execution, regardless of whether these statements are correct, it will be recorded. Since the database operation command is likely to perform very large and more frequent, so the query log after the open, the database may need to keep a written query log, this will increase the pressure on the server IO, add a lot of overhead, affect the performance of the database, By default, it is turned off, not recommended to open.

Stored query logs ways:

  Mode 1: The query logs stored in the specified log file;

  Option 2: The query logs on mysql.general_log table;

  Mode 3: The query log while stored in a log file specified general_log table with mysql library.

1, view the query log parameters

MariaDB [mysql]> show global variables like '%gen%log%';
+------------------+----------+
| Variable_name    | Value    |
+------------------+----------+
| general_log      | OFF      |
| general_log_file | ren7.log |
+------------------+----------+
2 rows in set (0.00 sec)

MariaDB [mysql]> show variables where variable_name like '%general_log%' or variable_name='log_output';
+------------------+----------+
| Variable_name    | Value    |
+------------------+----------+
| general_log      | OFF      |
| general_log_file | ren7.log |
| log_output       | FILE     |
+------------------+----------+
3 rows in set (0.00 sec)

2, query log variable Detailed

1  general_log: Specifies whether to open the query log (ON represents the open, OFF means not turned on by default OFF)
 2  general_log_file: When log_output set to "FILE", designated to save the query log to which file, what is his name, the default host name the same, generally located at / var / lib / mysql directory
 . 3 log_output:            Specifies the record to save the query what position ( "NONE", "the FILE", "TABLE", "the FILE, TABLE")
 . 4  File : save as a file
 . 5  table : saved as a table
 . 6 none: not recorded

 

Guess you like

Origin www.cnblogs.com/renyz/p/11480909.html