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
- Path does not have spaces
- Backslashes are best written in the path below Linux
- 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