MySQL enable logging, and view logs

Source: Internet
Author: User

MySQL has the following several logs:

Error log:-log-err

Query log:-log

Slow query log:-log-slow-queries

Update log:-log-update

Binary log:-log-bin

Whether logging is enabled

Mysql>show variables like ' log_% ';

How to know the current log

Mysql> Show master status;

Display binary Log numbers

Mysql> show master logs;

See binary log file with Mysqlbinlog

Shell>mysqlbinlog mail-bin.000001

or Shell>mysqlbinlog mail-bin.000001 | Tail

Specify the output location of the log in the configuration file.

The windows:windows configuration file is My.ini, usually under the MySQL installation directory or c:/windows.

The Linux:linux configuration file is my.cnf, usually under/etc.

Under Linux:

SQL code

# input in [mysqld]

#log

Log-error=/usr/local/mysql/log/error.log

Log=/usr/local/mysql/log/mysql.log

long_query_time=2

log-slow-queries=/usr/local/mysql/log/slowquery.log

[SQL]

# input in [mysqld]

#log

Log-error=/usr/local/mysql/log/error.log

Log=/usr/local/mysql/log/mysql.log

long_query_time=2

log-slow-queries=/usr/local/mysql/log/slowquery.log

Under Windows:

SQL code

# input in [mysqld]

#log

Log-error= "E:/progra~1/easyph~1.0b1/mysql/logs/error.log"

Log= "E:/progra~1/easyph~1.0b1/mysql/logs/mysql.log"

long_query_time=2

Log-slow-queries= "E:/progra~1/easyph~1.0b1/mysql/logs/slowquery.log"

[SQL]

# input in [mysqld]

#log

Log-error= "E:/progra~1/easyph~1.0b1/mysql/logs/error.log"

Log= "E:/progra~1/easyph~1.0b1/mysql/logs/mysql.log"

long_query_time=2

Log-slow-queries= "E:/progra~1/easyph~1.0b1/mysql/logs/slowquery.log"

Turn on Slow query

Long_query_time = 2--refers to the execution of more than how long SQL will be log down, here is 2 seconds

log-slow-queries=/usr/local/mysql/log/slowquery.log--Log the query back to a slower statement

Log-queries-not-using-indexes = nouseindex.log--literally, log down. Query with no index

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.