mysql日志文件

errorlog日志

记录mysql运行过程中Error、Warning、Note等信息

sql语句查看日志存储位置

mysql> show variables like "log_error";
+---------------+---------------------------------+
| Variable_name | Value                           |
+---------------+---------------------------------+
| log_error     | /var/log/mysqld.log             |
+---------------+---------------------------------+
1 row in set (0.00 sec)

error配置项

[mysqld]
log-error=/data/log/mysql/mysql_error.log

General Query Log日志

记录mysql的日常日志,包括查询、修改、更新等。

sql语句查看是否开启以存储位置

mysql> show global variables like "%genera%";
+----------------------------------------+--------------------+
| Variable_name                          | Value              |
+----------------------------------------+--------------------+
| auto_generate_certs                    | ON                 |
| general_log                            | OFF                |
| general_log_file                       | /data/mysql/JD.log |
| sha256_password_auto_generate_rsa_keys | ON                 |
+----------------------------------------+--------------------+
4 rows in set (0.01 sec)

Query配置项

[mysqld]
  general_log             = 1
  general_log_file        = /data/log/mysql/mysql_query.log

mysql开启/关闭

mysql> set global general_log = on;
mysql> set global general_log = off;

Slow Query Log

记录Mysql 慢查询的日志

mysql> show variables like "%slow%";
+---------------------------+-------------------------+
| Variable_name             | Value                   |
+---------------------------+-------------------------+
| log_slow_admin_statements | OFF                     |
| log_slow_slave_statements | OFF                     |
| slow_launch_time          | 2                       |
| slow_query_log            | OFF                     |
| slow_query_log_file       | /data/mysql/JD-slow.log |
+---------------------------+-------------------------+
5 rows in set (0.00 sec)

慢查询配置项

  slow-query-log = 1
  #设置满请求时间, 设置查多少秒的查询算是慢查询
  long_query_time = 1 
  slow-query-log-file = /data/log/mysql/mysql_slow.log

mysql开启

mysql> set global slow_query_log = on;

你可能感兴趣的