mysql dba系統學習(8)查詢記錄檔功能

來源:互聯網
上載者:User

查詢日誌的作用是記錄所有用戶端發來的sql語句,也就是記錄用戶端的所有操作

Log參數將要過時,現在用general_log來代替

開啟查詢日誌功能

mysql> showvariables like "%log";

+----------------+-------+

| Variable_name| Value |

+----------------+-------+

| back_log| 50|

| general_log| OFF|

| log| OFF|

| relay_log||

| slow_query_log | OFF|

| sync_binlog| 0|

+----------------+-------+

6 rows in set (0.01 sec)

mysql> set global general_log=1;

Query OK, 0 rows affected (0.18 sec)

mysql> set globallog=1;

Query OK, 0 rows affected, 1 warning (0.00sec)

mysql> showvariables like "%log";

+----------------+-------+

| Variable_name| Value |

+----------------+-------+

| back_log| 50|

| general_log| ON|

| log| ON|

| relay_log||

| slow_query_log | OFF|

| sync_binlog| 0|

+----------------+-------+

6 rows in set (0.00 sec)

也可以在my.cnf中添加參數

general_log=1

general_log_file=/tmp/chenzhongyang.log這樣來設定

mysql> show variables like"%file";

+---------------------+-----------------------------------------+

| Variable_name| Value|

+---------------------+-----------------------------------------+

| ft_stopword_file| (built-in)|

| general_log_file| /tmp/chenzhongyang.log|

| init_file||

| local_infile| ON|

| pid_file|/usr/local/mysql/var/test4.wolf.org.pid |

| relay_log_info_file | relay-log.info|

| slow_query_log_file |/usr/local/mysql/var/test4-slow.log|

+---------------------+-----------------------------------------+

查看本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/

查看記錄檔的內容

[root@test4 ~]# tail -f/tmp/chenzhongyang.log

/usr/local/mysql/libexec/mysqld, Version:5.1.70-log (Source distribution). started with:

Tcp port: 3306Unix socket: /tmp/mysql.sock

TimeId CommandArgument

130903 16:09:431 Connectroot@localhost on

1 Queryselect@@version_comment limit 1

130903 16:10:141 Queryshow variables like "%file"

130903 16:12:091 Queryselect * fromtt

130903 16:12:161 QuerySELECT DATABASE()

1 Init DBtest

130903 16:12:181 Queryselect * fromtt

一般情況下我們不開啟查詢日誌功能,因為他對系統效率的影響很大

管理查詢記錄檔

一般的記錄檔會很大,所以要處理日誌

[root@test4 ~]# mysqladminflush-logs;重新整理日誌所有記錄檔

出處:http://wolfword.blog.51cto.com/4892126/1287978

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.