共计 1528 个字符,预计需要花费 4 分钟才能阅读完成。
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;
正文完