MySQL DBA system Learning (8) query log file features

Source: Internet
Author: User
Tags dba

The function of the query log is to record all the SQL statements sent by the client, that is, to record all operations of the client

Log parameter is going to be obsolete, now replace with General_log

Open Query Log Feature

Mysql> showvariables like "%log";

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

| variable_name| Value |

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

| Back_log| 30:

| 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| 30:

| General_log| on|

| Log| on|

| relay_log| |

| Slow_query_log | Off|

| Sync_binlog| 0|

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

6 rows in Set (0.00 sec)

You can also add parameters to the MY.CNF

General_log=1

General_log_file=/tmp/chenzhongyang.log this to set

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|

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

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/

Viewing the contents of a log file

[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

In general, we do not open the query log function, because he has a great impact on system efficiency

Managing Query log Files

General log files will be very large, so to process the log

[Root@test4 ~]# mysqladminflush-logs; refresh log all log files

Source: http://wolfword.blog.51cto.com/4892126/1287978

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.