mysql 日誌之普通查詢日誌
預設情況下查詢日誌是關閉的。由於查詢日誌會記錄使用者的所有操作,其中還包含增刪查改等資訊,在併發操作大的環境下會產生大量的資訊從而導致不必要的磁碟IO,會影響mysql的效能的。如若不是為了除錯資料庫的目的建議不要開啟查詢日誌。
控制的引數
| general_log | OFF |
| general_log_file | /mysql/data/localhost.log |
開啟這2個引數刻意透過修改全量立即生效 還可以透過修改my.cnf來進行控制
1. 修改全域性變數
mysql> show variables like "%general_log_file%";
+------------------+------------------------+
| Variable_name | Value |
+------------------+------------------------+
| general_log_file | /mysql/log/general.log |
+------------------+------------------------+
1 row in set (0.00 sec)
mysql> set global general_log=1;
Query OK, 0 rows affected (0.33 sec)
mysql> show variables like "%general_log%";
+------------------+------------------------+
| Variable_name | Value |
+------------------+------------------------+
| general_log | ON |
| general_log_file | /mysql/log/general.log |
+------------------+------------------------+
2 rows in set (0.00 sec)
這個時候做操作
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| tts |
+--------------------+
5 rows in set (0.00 sec)
mysql> use tts
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables
-> ;
+---------------+
| Tables_in_tts |
+---------------+
| person |
| pet |
| shirt |
+---------------+
3 rows in set (0.00 sec)
mysql> select * from shirt;
+----+---------+--------+-------+
| id | style | color | owner |
+----+---------+--------+-------+
| 1 | polo | blue | 1 |
| 2 | dress | white | 1 |
| 3 | t-shirt | blue | 1 |
| 4 | dress | orange | 1 |
| 5 | polo | red | 1 |
| 6 | dress | blue | 1 |
| 7 | t-shirt | white | 1 |
+----+---------+--------+-------+
7 rows in set (0.00 sec)
mysql> create table a1 (a int);
Query OK, 0 rows affected (0.56 sec)
mysql> insert into a1 values (1);
Query OK, 1 row affected (0.00 sec)
mysql> select * from a1;
+------+
| a |
+------+
| 1 |
+------+
1 row in set (0.00 sec)
檢視查詢日誌
[root@localhost log]# tail -f general.log
/mysql/bin/mysqld, Version: 5.6.25-enterprise-commercial-advanced (MySQL Enterprise Server - Advanced Edition (Commercial)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
150615 10:20:20 1 Query show variables like "%general_log%"
150615 10:20:55 1 Query SELECT DATABASE()
150615 10:21:04 1 Query show databases
150615 10:21:08 1 Query SELECT DATABASE()
1 Init DB tts
1 Query show databases
1 Query show tables
1 Field List person
150615 10:21:09 1 Field List pet
1 Field List shirt
150615 10:21:13 1 Query show tables
150615 10:21:17 1 Query select * from shirt
150615 10:21:52 1 Query create table a1 (a int)
150615 10:21:58 1 Query insert into a1 values (1)
150615 10:22:15 1 Query select * from a1
2.修改my.cnf檔案
[root@localhost mysql]# cat my.cnf
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir = /mysql/data
server-id = 1
#error log
log-error = /mysql/log/mysql.log
log-warnings = 1
#querry log
general_log=1
general_log_file=/tmp/mysql/query.log
啟動資料庫就可以了
控制的引數
| general_log | OFF |
| general_log_file | /mysql/data/localhost.log |
開啟這2個引數刻意透過修改全量立即生效 還可以透過修改my.cnf來進行控制
1. 修改全域性變數
mysql> show variables like "%general_log_file%";
+------------------+------------------------+
| Variable_name | Value |
+------------------+------------------------+
| general_log_file | /mysql/log/general.log |
+------------------+------------------------+
1 row in set (0.00 sec)
mysql> set global general_log=1;
Query OK, 0 rows affected (0.33 sec)
mysql> show variables like "%general_log%";
+------------------+------------------------+
| Variable_name | Value |
+------------------+------------------------+
| general_log | ON |
| general_log_file | /mysql/log/general.log |
+------------------+------------------------+
2 rows in set (0.00 sec)
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| tts |
+--------------------+
5 rows in set (0.00 sec)
mysql> use tts
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables
-> ;
+---------------+
| Tables_in_tts |
+---------------+
| person |
| pet |
| shirt |
+---------------+
3 rows in set (0.00 sec)
mysql> select * from shirt;
+----+---------+--------+-------+
| id | style | color | owner |
+----+---------+--------+-------+
| 1 | polo | blue | 1 |
| 2 | dress | white | 1 |
| 3 | t-shirt | blue | 1 |
| 4 | dress | orange | 1 |
| 5 | polo | red | 1 |
| 6 | dress | blue | 1 |
| 7 | t-shirt | white | 1 |
+----+---------+--------+-------+
7 rows in set (0.00 sec)
mysql> create table a1 (a int);
Query OK, 0 rows affected (0.56 sec)
mysql> insert into a1 values (1);
Query OK, 1 row affected (0.00 sec)
mysql> select * from a1;
+------+
| a |
+------+
| 1 |
+------+
1 row in set (0.00 sec)
[root@localhost log]# tail -f general.log
/mysql/bin/mysqld, Version: 5.6.25-enterprise-commercial-advanced (MySQL Enterprise Server - Advanced Edition (Commercial)). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
150615 10:20:20 1 Query show variables like "%general_log%"
150615 10:20:55 1 Query SELECT DATABASE()
150615 10:21:04 1 Query show databases
150615 10:21:08 1 Query SELECT DATABASE()
1 Init DB tts
1 Query show databases
1 Query show tables
1 Field List person
150615 10:21:09 1 Field List pet
1 Field List shirt
150615 10:21:13 1 Query show tables
150615 10:21:17 1 Query select * from shirt
150615 10:21:52 1 Query create table a1 (a int)
150615 10:21:58 1 Query insert into a1 values (1)
150615 10:22:15 1 Query select * from a1
2.修改my.cnf檔案
[root@localhost mysql]# cat my.cnf
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir = /mysql/data
server-id = 1
#error log
log-error = /mysql/log/mysql.log
log-warnings = 1
#querry log
general_log=1
general_log_file=/tmp/mysql/query.log
啟動資料庫就可以了
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22039464/viewspace-1731506/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql 日誌之慢查詢日誌MySql
- MySQL資料庫中的日誌檔案---(2)普通查詢日誌MySql資料庫
- mysql 查詢日誌MySql
- mysql查詢日誌MySql
- mysql之 日誌體系(錯誤日誌、查詢日誌、二進位制日誌、事務日誌、中繼日誌)MySql中繼
- MySQL:慢查詢日誌MySql
- MySQL 通用查詢日誌MySql
- mysql慢查詢日誌MySql
- 關於MySQL 通用查詢日誌和慢查詢日誌分析MySql
- mysql之 slow log 慢查詢日誌MySql
- 【MySql】 慢日誌查詢工具之mysqlslaMySql
- 【MySql】mysql 慢日誌查詢工具之mysqldumpslowMySql
- PHP慢指令碼日誌和Mysql的慢查詢日誌PHP指令碼MySql
- mysql 日誌之錯誤日誌MySql
- 【MySQL】慢查詢日誌不列印MySql
- mysqlsla 分析mysql慢查詢日誌MySql
- MySQL Slow Query log(慢查詢日誌)MySql
- mysql慢查詢日誌分析工具使用MySql
- Mysql慢查詢日誌分析工具mysqlslaMySql
- MySQL資料庫中的日誌檔案---(3)慢查詢日誌MySql資料庫
- 日誌查詢錯誤
- 使用慢查詢日誌
- loki的日誌查詢Loki
- MySQL慢查詢日誌相關設定MySql
- 【轉載】MySQL慢查詢日誌總結MySql
- mysql慢查詢和錯誤日誌分析MySql
- MYSQL開啟慢查詢日誌實施MySql
- mysql開啟檢視慢查詢日誌MySql
- 用命令過濾MySQL慢查詢日誌MySql
- Mysql慢查詢日誌檔案轉ExcelMySqlExcel
- 資料庫MySQL一般查詢日誌或者慢查詢日誌歷史資料的清理資料庫MySql
- 如何精準查詢日誌
- linux查詢日誌技巧Linux
- redo日誌組資訊查詢
- 記錄 sql 查詢日誌SQL
- 瞭解通用查詢日誌
- 慢查詢日誌的管理
- lumen cli日誌和普通日誌分開儲存