MySQL Log Management in Windows (similar to Linux) 1.1 and mysql1.1
Why do I need to enable database logs?
When multiple programs are using the database, our database sometimes fails. Why? No logs can be found, and the logs of each program cannot find the key reasons. Therefore, you must enable the log system of the database.
Control Log Size
To enable logs, you need to know how to control the log size. This is the first problem facing logs. Otherwise, you do not know which day the file system will be cracked.
Expire_logs_day = 3: Log Retention days. Logs over three days are automatically deleted.
How do I know if MySQL has enabled logs?
Execute the following statement to View Details:
show variables like 'log_%';
Enable logging to modify Database Configuration
If it is OFF, It is not enabled. If you want to enable it, you can add the following configuration information to the my. ini file in the Mysql root directory (note that you must add it to [mysqld ].
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"
Note:
Log: enables query logs, which records every action and detail of SQL queries. It consumes a lot of database IO and is only enabled for a short time during debugging. It is not recommended to enable this function at ordinary times.
Log-error: error log
Log-bin: binary log
Log-slow-queries: slow query logs. query statements that record the number of seconds after the ong_query_time are recorded in the log file specified by this variable.
5 In long_query_time = 5: indicates that the query is recorded in the log-slow-queries after more than five seconds.
Expire_logs_day = 3: Log Retention days. Logs over three days are automatically deleted.
Restart Mysql Service
Check whether Log service is enabled
You can see the log service to start
View log files
The generated log file is displayed.
View logs
You can see that the operations you performed on the database are recorded in the log file.
Note:
Set the Log Size
You certainly do not want to print logs in real time, and disable your file system.
For more information about log configuration in Linux, see http://www.blogjava.net/dongbule/archive/2010/09/04/331050.htmlclick to open a link.