MySQL中開啟和使用通用查詢?nèi)罩镜膶嵗坛?/h1>
更新時間:2015年12月23日 17:37:58 作者:沙彌的世界
這篇文章主要介紹了MySQL中開啟和使用通用查詢?nèi)罩镜膶嵗坛?包括其備份和關(guān)閉等基礎(chǔ)操作的例子講解,需要的朋友可以參考下
開啟通用查詢?nèi)罩?br />
因為為了性能考慮,一般通用查詢?nèi)罩緂eneral log不會開啟。slow log可以定位一些有性能問題的sql,而general log會記錄所有的SQL。
mysql5.0版本,如果要開啟slow log、general log,需要重啟,從MySQL5.1.6版開始,general query log和slow query log開始支持寫到文件或者數(shù)據(jù)庫表兩種方式,并且日志的開啟,輸出方式的修改,都可以在Global級別動態(tài)修改。
mysql>select version();
+————+
| version() |
+————+
| 5.1.37-log |
+————+
1 row in set (0.02 sec)
設(shè)置日志輸出方式為文件(如果設(shè)置log_output=table的話,則日志結(jié)果會記錄到名為gengera_log的表中,這表的默認(rèn)引擎都是CSV):
mysql>set global log_output=file;
Query OK, 0 rows affected (0.00 sec)
設(shè)置general log的日志文件路徑:
mysql>set global general_log_file='/tmp/general.log';
Query OK, 0 rows affected (0.00 sec)
開啟general log:
mysql>set global general_log=on;
Query OK, 0 rows affected (0.02 sec)
過一段時間后,關(guān)閉general log:
mysql>set global general_log=off;
Query OK, 0 rows affected (0.02 sec)
通用查詢?nèi)罩镜南到y(tǒng)變量
log_output=[none|file|table|file,table] #通用查詢?nèi)罩据敵龈袷?
general_log=[on|off] #是否啟用通用查詢?nèi)罩?
general_log_file[=filename] #通用查詢?nèi)罩疚恢眉懊?
通用查詢?nèi)罩镜膫浞?/strong>
在Linux或Unix中,你可以通過下面的命令重新命名文件
并創(chuàng)建一個新文件:
shell> mv hostname.log hostname-old.log
shell> mysqladmin flush-logs
shell> cp hostname-old.log to-backup-directory
shell> rm hostname-old.log
在Windows中,服務(wù)器打開日志文件期間不能重新命名日志文件。必須先停止服務(wù)器然后重新命名日志文件。然后重啟服務(wù)器來創(chuàng)建新日志文件。
演示通用查詢?nèi)罩镜氖褂?/strong>
a、啟用通用查詢?nèi)罩?br />
--演示環(huán)境
root@localhost[(none)]> show variables like '%version%';
+-------------------------+------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------+
| innodb_version | 5.5.39 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.39-log |
| version_comment | MySQL Community Server (GPL) |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+------------------------------+
--查看系統(tǒng)變量
root@localhost[(none)]> show variables like '%general%';
+------------------+----------------------------+
| Variable_name | Value |
+------------------+----------------------------+
| general_log | OFF |
| general_log_file | /var/lib/mysql/suse11b.log |
+------------------+----------------------------+
--查看當(dāng)前的通用日志,顯示無日志文件
root@localhost[(none)]> system ls /var/lib/mysql/suse11b.log
ls: cannot access /var/lib/mysql/suse11b.log: No such file or directory
--設(shè)置變量general_log以開啟通用查詢?nèi)罩?
root@localhost[(none)]> set @@global.general_log=1;
Query OK, 0 rows affected (0.00 sec)
--再次查看通用日志文件已存在
root@localhost[(none)]> system ls /var/lib/mysql/suse11b.log
/var/lib/mysql/suse11b.log
root@localhost[(none)]> select * from tempdb.tb1; --執(zhí)行查詢
+------+------+
| id | val |
+------+------+
| 1 | jack |
+------+------+
--查看通用日志文件內(nèi)容
root@localhost[(none)]> system more /var/lib/mysql/suse11b.log
/usr/sbin/mysqld, Version: 5.5.39-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
141003 16:18:12 4 Query show variables like '%general%'
141003 16:18:55 4 Query select * from tempdb.tb1
b、更改通用查詢?nèi)罩疚恢?br />
root@localhost[(none)]> exit
Bye
suse11b:~ # service mysql stop
Shutting down MySQL... done
suse11b:~ # mysqld --general_log_file=/tmp/suse11b.log --user=mysql &
[1] 47009
suse11b:~ # ps -ef|grep mysql|grep -v grep
mysql 47009 44514 1 16:22 pts/0 00:00:00 mysqld --general_log_file=/tmp/suse11b.log --user=mysql
root 47053 44514 0 16:22 pts/0 00:00:00 grep mysql
suse11b:~ # mysql
root@localhost[(none)]> system ls /tmp/suse11b.log
ls: cannot access /tmp/suse11b.log: No such file or directory
root@localhost[(none)]> show variables like '%gener%';
+------------------+------------------+
| Variable_name | Value |
+------------------+------------------+
| general_log | OFF |
| general_log_file | /tmp/suse11b.log |
+------------------+------------------+
root@localhost[(none)]> set global general_log=on;
Query OK, 0 rows affected (0.01 sec)
--此時從系統(tǒng)變量看出,通用日志已經(jīng)到/tmp目錄下
root@localhost[(none)]> show variables like '%gener%';
+------------------+------------------+
| Variable_name | Value |
+------------------+------------------+
| general_log | ON |
| general_log_file | /tmp/suse11b.log |
+------------------+------------------+
--發(fā)布查詢
root@localhost[(none)]> select count(*) from tempdb.tb1;
+----------+
| count(*) |
+----------+
| 1 |
+----------+
--查看通用日志文件內(nèi)容
root@localhost[(none)]> system more /tmp/suse11b.log
mysqld, Version: 5.5.39-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
141003 16:30:03 1 Query show variables like '%gener%'
141003 16:30:09 1 Query select count(*) from tempdb.tb1
c、通用查詢?nèi)罩据敵龇绞?br />
--可以輸出為文件,表以及不輸出,即TABLE,F(xiàn)ILE,NONE
--系統(tǒng)變量log_output
root@localhost[(none)]> show variables like 'log_output';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | FILE |
+---------------+-------+
--下面修改為輸出為表方式
root@localhost[(none)]> set global log_output='TABLE';
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> show variables like 'log_output';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | TABLE |
+---------------+-------+
--發(fā)布查詢
root@localhost[(none)]> select * from tempdb.tb1;
+------+------+
| id | val |
+------+------+
| 1 | jack |
+------+------+
root@localhost[(none)]> system more /tmp/suse11b.log
mysqld, Version: 5.5.39-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
141003 16:30:03 1 Query show variables like '%gener%'
141003 16:30:09 1 Query select count(*) from tempdb.tb1
141003 16:31:00 1 Query show variables like 'log_output'
141003 17:00:48 1 Query set global log_output='TABLE' #通用查詢?nèi)罩据敵龅轿募H僅記錄到全局變量的修改
--mysql.general_log記錄了通用查詢?nèi)罩镜男畔?
root@localhost[(none)]> desc mysql.general_log;
+--------------+------------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+------------------+------+-----+-------------------+-----------------------------+
| event_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| user_host | mediumtext | NO | | NULL | |
| thread_id | int(11) | NO | | NULL | |
| server_id | int(10) unsigned | NO | | NULL | |
| command_type | varchar(64) | NO | | NULL | |
| argument | mediumtext | NO | | NULL | |
+--------------+------------------+------+-----+-------------------+-----------------------------+
--從通用查詢?nèi)罩颈砝锊榭赐ㄓ貌樵內(nèi)罩镜膬?nèi)容
root@localhost[(none)]> select thread_id,command_type,argument from mysql.general_log;
+-----------+--------------+---------------------------------------------------------------+
| thread_id | command_type | argument |
+-----------+--------------+---------------------------------------------------------------+
| 1 | Query | show variables like 'log_output' |
| 1 | Query | select * from tempdb.tb1 |
| 1 | Query | desc mysql.general_log |
| 1 | Query | select thread_id,command_type,argument from mysql.general_log |
+-----------+--------------+---------------------------------------------------------------+
root@localhost[(none)]> show variables like 'log_output';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | TABLE |
+---------------+-------+
--使用FILE,TABLE 2者混合輸出通用日志
root@localhost[(none)]> set global log_output='file,table';
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> select @@global.log_output;
+---------------------+
| @@global.log_output |
+---------------------+
| FILE,TABLE |
+---------------------+
root@localhost[(none)]> insert into tempdb.tb1 values(2,'robinson');
Query OK, 1 row affected (0.06 sec)
root@localhost[(none)]> commit;
Query OK, 0 rows affected (0.01 sec)
--驗證結(jié)果,表和文件里邊存在通用的日志記錄
root@localhost[(none)]> system tail /tmp/suse11b.log|grep robinson
141003 17:41:54 2 Query insert into tempdb.tb1 values(2,'robinson')
root@localhost[(none)]> select thread_id,command_type,argument from mysql.general_log
-> where argument like '%robinson%';
+-----------+--------------+------------------------------------------------------------------------+
| thread_id | command_type | argument |
+-----------+--------------+------------------------------------------------------------------------+
| 2 | Query | insert into tempdb.tb1 values(2,'robinson') |
| 2 | Query | select thread_id,command_type,argument from mysql.general_log |
| | | where argument like ''robinson'' |
+-----------+--------------+------------------------------------------------------------------------+
d、關(guān)閉通用查詢?nèi)罩?br />
--可以通過設(shè)置系統(tǒng)變量general_log來關(guān)閉通用查詢?nèi)罩荆藭r日志輸出設(shè)置為FILE,TABLE
root@localhost[(none)]> show variables like 'log_output';
+---------------+------------+
| Variable_name | Value |
+---------------+------------+
| log_output | FILE,TABLE |
+---------------+------------+
root@localhost[(none)]> set global general_log=off;
Query OK, 0 rows affected (0.01 sec)
root@localhost[(none)]> show variables like '%gener%';
+------------------+------------------+
| Variable_name | Value |
+------------------+------------------+
| general_log | OFF |
| general_log_file | /tmp/suse11b.log |
+------------------+------------------+
root@localhost[(none)]> delete from tempdb.tb1 where id=2;
Query OK, 1 row affected (0.12 sec)
root@localhost[(none)]> commit;
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> system tail -n 1 /tmp/suse11b.log
141003 17:45:13 2 Query set global general_log=off
root@localhost[(none)]> select thread_id,command_type,argument from mysql.general_log
-> where argument like '%delete%';
Empty set (0.00 sec)
--從上面的演示可知,盡管我們設(shè)置了log_output為FILE,TABLE,但general_log為OFF,通用日志無任何記錄產(chǎn)生
root@localhost[(none)]> set global log_output=none;
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> set global general_log=1;
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> truncate table tempdb.tb1;
Query OK, 0 rows affected (0.01 sec)
root@localhost[(none)]> system tail -n 1 /tmp/suse11b.log
Time Id Command Argument
--通過上面的演示,在log_output=none,general_log=on的清下下無任何通用日志輸出。
相關(guān)文章
-
MySQL實例精講單行函數(shù)以及字符數(shù)學(xué)日期流程控制
SQL函數(shù)即數(shù)據(jù)庫的內(nèi)置函數(shù),可以運用在SQL語句中實現(xiàn)特定的功能。SQL單行函數(shù)對于每一行數(shù)據(jù)進行計算后得到一行輸出結(jié)果。SQL單行函數(shù)根據(jù)數(shù)據(jù)類型分為字符函數(shù)、數(shù)字函數(shù)、日期函數(shù)、轉(zhuǎn)換函數(shù),另外還有一些別的函數(shù) 2021-10-10
-
SQL 四種連接-左外連接、右外連接、內(nèi)連接、全連接詳解
這篇文章主要介紹了SQL 四種連接-左外連接、右外連接、內(nèi)連接、全連接詳解的相關(guān)資料,需要的朋友可以參考下 2016-11-11
-
Mysql錯誤:Too many connections的解決方法
這篇文章主要給大家介紹了關(guān)于Mysql錯誤Too many connections的解決方法,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Mysql具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
2019-06-06
-
MySQL MyISAM默認(rèn)存儲引擎實現(xiàn)原理
這篇文章主要介紹了MySQL MyISAM默認(rèn)存儲引擎實現(xiàn)原理,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下 2020-03-03
最新評論
開啟通用查詢?nèi)罩?br /> 因為為了性能考慮,一般通用查詢?nèi)罩緂eneral log不會開啟。slow log可以定位一些有性能問題的sql,而general log會記錄所有的SQL。
mysql5.0版本,如果要開啟slow log、general log,需要重啟,從MySQL5.1.6版開始,general query log和slow query log開始支持寫到文件或者數(shù)據(jù)庫表兩種方式,并且日志的開啟,輸出方式的修改,都可以在Global級別動態(tài)修改。
mysql>select version();
+————+ | version() | +————+ | 5.1.37-log | +————+ 1 row in set (0.02 sec)
設(shè)置日志輸出方式為文件(如果設(shè)置log_output=table的話,則日志結(jié)果會記錄到名為gengera_log的表中,這表的默認(rèn)引擎都是CSV):
mysql>set global log_output=file;
Query OK, 0 rows affected (0.00 sec)
設(shè)置general log的日志文件路徑:
mysql>set global general_log_file='/tmp/general.log';
Query OK, 0 rows affected (0.00 sec)
開啟general log:
mysql>set global general_log=on;
Query OK, 0 rows affected (0.02 sec)
過一段時間后,關(guān)閉general log:
mysql>set global general_log=off;
Query OK, 0 rows affected (0.02 sec)
通用查詢?nèi)罩镜南到y(tǒng)變量
log_output=[none|file|table|file,table] #通用查詢?nèi)罩据敵龈袷?
general_log=[on|off] #是否啟用通用查詢?nèi)罩? general_log_file[=filename] #通用查詢?nèi)罩疚恢眉懊?
通用查詢?nèi)罩镜膫浞?/strong>
在Linux或Unix中,你可以通過下面的命令重新命名文件
并創(chuàng)建一個新文件:
shell> mv hostname.log hostname-old.log shell> mysqladmin flush-logs shell> cp hostname-old.log to-backup-directory shell> rm hostname-old.log
在Windows中,服務(wù)器打開日志文件期間不能重新命名日志文件。必須先停止服務(wù)器然后重新命名日志文件。然后重啟服務(wù)器來創(chuàng)建新日志文件。
演示通用查詢?nèi)罩镜氖褂?/strong>
a、啟用通用查詢?nèi)罩?br />
--演示環(huán)境 root@localhost[(none)]> show variables like '%version%';
+-------------------------+------------------------------+ | Variable_name | Value | +-------------------------+------------------------------+ | innodb_version | 5.5.39 | | protocol_version | 10 | | slave_type_conversions | | | version | 5.5.39-log | | version_comment | MySQL Community Server (GPL) | | version_compile_machine | x86_64 | | version_compile_os | Linux | +-------------------------+------------------------------+
--查看系統(tǒng)變量 root@localhost[(none)]> show variables like '%general%';
+------------------+----------------------------+ | Variable_name | Value | +------------------+----------------------------+ | general_log | OFF | | general_log_file | /var/lib/mysql/suse11b.log | +------------------+----------------------------+
--查看當(dāng)前的通用日志,顯示無日志文件 root@localhost[(none)]> system ls /var/lib/mysql/suse11b.log
ls: cannot access /var/lib/mysql/suse11b.log: No such file or directory
--設(shè)置變量general_log以開啟通用查詢?nèi)罩? root@localhost[(none)]> set @@global.general_log=1;
Query OK, 0 rows affected (0.00 sec)
--再次查看通用日志文件已存在 root@localhost[(none)]> system ls /var/lib/mysql/suse11b.log /var/lib/mysql/suse11b.log root@localhost[(none)]> select * from tempdb.tb1; --執(zhí)行查詢
+------+------+ | id | val | +------+------+ | 1 | jack | +------+------+
--查看通用日志文件內(nèi)容 root@localhost[(none)]> system more /var/lib/mysql/suse11b.log /usr/sbin/mysqld, Version: 5.5.39-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock Time Id Command Argument 141003 16:18:12 4 Query show variables like '%general%' 141003 16:18:55 4 Query select * from tempdb.tb1
b、更改通用查詢?nèi)罩疚恢?br />
root@localhost[(none)]> exit
Bye suse11b:~ # service mysql stop Shutting down MySQL... done suse11b:~ # mysqld --general_log_file=/tmp/suse11b.log --user=mysql & [1] 47009 suse11b:~ # ps -ef|grep mysql|grep -v grep mysql 47009 44514 1 16:22 pts/0 00:00:00 mysqld --general_log_file=/tmp/suse11b.log --user=mysql root 47053 44514 0 16:22 pts/0 00:00:00 grep mysql suse11b:~ # mysql
root@localhost[(none)]> system ls /tmp/suse11b.log
ls: cannot access /tmp/suse11b.log: No such file or directory
root@localhost[(none)]> show variables like '%gener%';
+------------------+------------------+ | Variable_name | Value | +------------------+------------------+ | general_log | OFF | | general_log_file | /tmp/suse11b.log | +------------------+------------------+
root@localhost[(none)]> set global general_log=on;
Query OK, 0 rows affected (0.01 sec)
--此時從系統(tǒng)變量看出,通用日志已經(jīng)到/tmp目錄下 root@localhost[(none)]> show variables like '%gener%';
+------------------+------------------+ | Variable_name | Value | +------------------+------------------+ | general_log | ON | | general_log_file | /tmp/suse11b.log | +------------------+------------------+
--發(fā)布查詢 root@localhost[(none)]> select count(*) from tempdb.tb1;
+----------+ | count(*) | +----------+ | 1 | +----------+
--查看通用日志文件內(nèi)容 root@localhost[(none)]> system more /tmp/suse11b.log
mysqld, Version: 5.5.39-log (MySQL Community Server (GPL)). started with: Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock Time Id Command Argument 141003 16:30:03 1 Query show variables like '%gener%' 141003 16:30:09 1 Query select count(*) from tempdb.tb1
c、通用查詢?nèi)罩据敵龇绞?br />
--可以輸出為文件,表以及不輸出,即TABLE,F(xiàn)ILE,NONE --系統(tǒng)變量log_output root@localhost[(none)]> show variables like 'log_output';
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_output | FILE | +---------------+-------+
--下面修改為輸出為表方式 root@localhost[(none)]> set global log_output='TABLE';
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> show variables like 'log_output';
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_output | TABLE | +---------------+-------+
--發(fā)布查詢 root@localhost[(none)]> select * from tempdb.tb1;
+------+------+ | id | val | +------+------+ | 1 | jack | +------+------+
root@localhost[(none)]> system more /tmp/suse11b.log
mysqld, Version: 5.5.39-log (MySQL Community Server (GPL)). started with: Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock Time Id Command Argument 141003 16:30:03 1 Query show variables like '%gener%' 141003 16:30:09 1 Query select count(*) from tempdb.tb1 141003 16:31:00 1 Query show variables like 'log_output' 141003 17:00:48 1 Query set global log_output='TABLE' #通用查詢?nèi)罩据敵龅轿募H僅記錄到全局變量的修改
--mysql.general_log記錄了通用查詢?nèi)罩镜男畔? root@localhost[(none)]> desc mysql.general_log;
+--------------+------------------+------+-----+-------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +--------------+------------------+------+-----+-------------------+-----------------------------+ | event_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | | user_host | mediumtext | NO | | NULL | | | thread_id | int(11) | NO | | NULL | | | server_id | int(10) unsigned | NO | | NULL | | | command_type | varchar(64) | NO | | NULL | | | argument | mediumtext | NO | | NULL | | +--------------+------------------+------+-----+-------------------+-----------------------------+
--從通用查詢?nèi)罩颈砝锊榭赐ㄓ貌樵內(nèi)罩镜膬?nèi)容 root@localhost[(none)]> select thread_id,command_type,argument from mysql.general_log;
+-----------+--------------+---------------------------------------------------------------+ | thread_id | command_type | argument | +-----------+--------------+---------------------------------------------------------------+ | 1 | Query | show variables like 'log_output' | | 1 | Query | select * from tempdb.tb1 | | 1 | Query | desc mysql.general_log | | 1 | Query | select thread_id,command_type,argument from mysql.general_log | +-----------+--------------+---------------------------------------------------------------+
root@localhost[(none)]> show variables like 'log_output';
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_output | TABLE | +---------------+-------+
--使用FILE,TABLE 2者混合輸出通用日志 root@localhost[(none)]> set global log_output='file,table';
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> select @@global.log_output;
+---------------------+ | @@global.log_output | +---------------------+ | FILE,TABLE | +---------------------+
root@localhost[(none)]> insert into tempdb.tb1 values(2,'robinson');
Query OK, 1 row affected (0.06 sec)
root@localhost[(none)]> commit;
Query OK, 0 rows affected (0.01 sec)
--驗證結(jié)果,表和文件里邊存在通用的日志記錄 root@localhost[(none)]> system tail /tmp/suse11b.log|grep robinson
141003 17:41:54 2 Query insert into tempdb.tb1 values(2,'robinson')
root@localhost[(none)]> select thread_id,command_type,argument from mysql.general_log -> where argument like '%robinson%';
+-----------+--------------+------------------------------------------------------------------------+ | thread_id | command_type | argument | +-----------+--------------+------------------------------------------------------------------------+ | 2 | Query | insert into tempdb.tb1 values(2,'robinson') | | 2 | Query | select thread_id,command_type,argument from mysql.general_log | | | | where argument like ''robinson'' | +-----------+--------------+------------------------------------------------------------------------+
d、關(guān)閉通用查詢?nèi)罩?br />
--可以通過設(shè)置系統(tǒng)變量general_log來關(guān)閉通用查詢?nèi)罩荆藭r日志輸出設(shè)置為FILE,TABLE
root@localhost[(none)]> show variables like 'log_output';
+---------------+------------+ | Variable_name | Value | +---------------+------------+ | log_output | FILE,TABLE | +---------------+------------+
root@localhost[(none)]> set global general_log=off;
Query OK, 0 rows affected (0.01 sec)
root@localhost[(none)]> show variables like '%gener%';
+------------------+------------------+ | Variable_name | Value | +------------------+------------------+ | general_log | OFF | | general_log_file | /tmp/suse11b.log | +------------------+------------------+
root@localhost[(none)]> delete from tempdb.tb1 where id=2;
Query OK, 1 row affected (0.12 sec)
root@localhost[(none)]> commit;
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> system tail -n 1 /tmp/suse11b.log
141003 17:45:13 2 Query set global general_log=off
root@localhost[(none)]> select thread_id,command_type,argument from mysql.general_log -> where argument like '%delete%';
Empty set (0.00 sec)--從上面的演示可知,盡管我們設(shè)置了log_output為FILE,TABLE,但general_log為OFF,通用日志無任何記錄產(chǎn)生
root@localhost[(none)]> set global log_output=none;
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> set global general_log=1;
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> truncate table tempdb.tb1;
Query OK, 0 rows affected (0.01 sec)
root@localhost[(none)]> system tail -n 1 /tmp/suse11b.log
Time Id Command Argument --通過上面的演示,在log_output=none,general_log=on的清下下無任何通用日志輸出。
相關(guān)文章
MySQL實例精講單行函數(shù)以及字符數(shù)學(xué)日期流程控制
SQL函數(shù)即數(shù)據(jù)庫的內(nèi)置函數(shù),可以運用在SQL語句中實現(xiàn)特定的功能。SQL單行函數(shù)對于每一行數(shù)據(jù)進行計算后得到一行輸出結(jié)果。SQL單行函數(shù)根據(jù)數(shù)據(jù)類型分為字符函數(shù)、數(shù)字函數(shù)、日期函數(shù)、轉(zhuǎn)換函數(shù),另外還有一些別的函數(shù)2021-10-10SQL 四種連接-左外連接、右外連接、內(nèi)連接、全連接詳解
這篇文章主要介紹了SQL 四種連接-左外連接、右外連接、內(nèi)連接、全連接詳解的相關(guān)資料,需要的朋友可以參考下2016-11-11Mysql錯誤:Too many connections的解決方法
這篇文章主要給大家介紹了關(guān)于Mysql錯誤Too many connections的解決方法,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Mysql具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06MySQL MyISAM默認(rèn)存儲引擎實現(xiàn)原理
這篇文章主要介紹了MySQL MyISAM默認(rèn)存儲引擎實現(xiàn)原理,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-03-03