MySQL enable logs, and view logs

Source: Internet
Author: User

MySQL has the following types of logs:
Error log:-log-err
Query log:-log
Slow query log:-log-slow-queries
Update log:-log-update
Binary log:-log-bin


Whether the log is enabled
Mysql>show variables like ' log_% ';

How to know the current log
Mysql> Show master status;

Show binary log Entries
Mysql> show master logs;

See binary log files 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 under C:\Windows.
The Linux:linux configuration file is my.cnf, usually in/etc.

Under Linux:

SQL code
    1. # Enter in [mysqld]
    2. #log
    3. log-error=/usr/Local/mysql/log/error.log
    4. log=/usr/Local/mysql/log/mysql.log
    5. long_query_time=2
    6. log-slow-queries=/usr/Local/mysql/log/slowquery.log



Under Windows:

SQL code
    1. # Enter in [mysqld]
    2. #log
    3. log-error="E:/progra~1/easyph~1.0b1/mysql/logs/error.log"
    4. log="E:/progra~1/easyph~1.0b1/mysql/logs/mysql.log"
    5. long_query_time=2
    6. log-slow-queries= "E:/progra~1/easyph~1.0b1/mysql/logs/slowquery.log"



Turn on Slow query
Long_query_time = 2-refers to how long the SQL executed 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 without using the indexed query

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.