MySQL 通用查询日志
首先推荐一款linux下的mysql客户端mycli
mysql里面有很多日志,如bin日志用来恢复数据,慢查询日志用来监控查询较慢的数据
只记了通用日志的开启方式,其他的日志都是类似命令
mysql root@localhost:(none)> show global variables like '%gener%';
+------------------+--------------------------------------------+
| Variable_name | Value |
|------------------+--------------------------------------------|
| general_log | OFF |
| general_log_file | /var/lib/mysql/iZwz92pw32r9w6beu4jlfpZ.log |
+------------------+--------------------------------------------+
mysql root@localhost:(none)> SET global general_log = ON;
Query OK, 0 rows affected
Time: 0.001s
mysql root@localhost:(none)> show global variables like '%gener%';
+------------------+--------------------------------------------+
| Variable_name | Value |
|------------------+--------------------------------------------|
| general_log | ON |
| general_log_file | /var/lib/mysql/iZwz92pw32r9w6beu4jlfpZ.log |
+------------------+--------------------------------------------+
日志也可以记到数据库里面,不输出到文件里
mysql root@localhost:(none)> show variables like 'log_output'
+-----------------+---------+
| Variable_name | Value |
|-----------------+---------|
| log_output | FILE |
+-----------------+---------+
mysql root@localhost:(none)> SET global log_output = 'table';
Query OK, 0 rows affected
Time: 0.001s
mysql root@localhost:(none)> show variables like 'log_output'
+-----------------+---------+
| Variable_name | Value |
|-----------------+---------|
| log_output | TABLE |
+-----------------+---------+
mysql root@localhost:(none)> set global log_output = 'file';
Query OK, 0 rows affected
Time: 0.001s
mysql root@localhost:(none)> show variables like 'log_output'
+-----------------+---------+
| Variable_name | Value |
|-----------------+---------|
| log_output | FILE |
+-----------------+---------+