MySQL Log management under Windows (Linux similar) 1.1

Source: Internet
Author: User

Why do I want to open a database log

When a number of programs are using the database, our database sometimes actually hang up, to find out why? Found no log can be checked, each program's own log can not find the key reasons. So to open the database log system.

Control Log Size

To open the log premise is to know how to control the size of the log, this is the general log to face the first problem, or do not know which day the file system to explode, the same egg broken.

Expire_logs_day=3: Log saved days, logs older than three days are automatically deleted

How do I know if MySQL has a log open?

Execute the following statement to view:

Show variables like ' log_% ';


To change the database configuration by turning on the log

Off is not turned on, if you want to open the MySQL root directory under the My.ini file to add the following configuration information (note to add to [mysqld] inside

Log-error= "D:/log/mysql/mysql_log_err.txt" log= "D:/log/mysql/mysql_log.txt" #log-bin= "D:/log/mysql/mysql_log_bin "Log-slow-queries=" D:/log/mysql/mysql_log_slow.txt "
Description

LOG: Open the query log, this will record every action and detail of SQL query, very consumption of database IO, only in the time of debugging, open for a short time, usually is not recommended to open.

Log-error: Error Log

Log-bin: Binary Log

Log-slow-queries: A slow query log that records query statements whose query time exceeds the number of seconds defined by Ong_query_time is recorded in the log file specified by this variable.

Long_query_time=5:5 indicates that the query is more than five seconds before it is recorded in the log specified by Log-slow-queries.

Expire_logs_day=3: Log saved days, logs older than three days are automatically deleted



Restart MySQL Service

To see if the log service is turned on

You can see the log service to start


viewing log files

You can see the generated log files


View Logs

You can see that the operations you have just made on the database are recorded in the log file.


Note

    1. Path does not have spaces
    2. Backslashes are best written in the path below Linux
    3. Do not write the comment in a line starting with the # sign

Set the size of the log

You don't want the logs to print in real time, to hang up your file system.


Linux Log Configuration reference: http://www.blogjava.net/dongbule/archive/2010/09/04/331050.html Click to open the link


MySQL Log management under Windows (Linux similar) 1.1

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.