Whether logs are enabled
Mysql> show variables like 'Log _ bin ';
How to know the current log
Mysql> show Master status;
Use mysqlbinlog to view binary log files
Shell> mysqlbinlog mail-bin.000001 (to write absolute problem path D ://)
Or shell> mysqlbinlog mail-bin.000001 | tail
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
In the installation directory of MySQL, open my. ini, add the above parameters to the end, save and restart the MySQL service.
For example:
# Enter a name for the error log file. Otherwise a default name will be used.
Log-error = err. Log
# Enter a name for the query log file. Otherwise a default name will be used.
# Log =
# Enter a name for the slow query log file. Otherwise a default name will be used.
# Log-Slow-queries =
# Enter a name for the update log file. Otherwise a default name will be used.
# Log-update =
# Enter a name for the binary log. Otherwise a default name will be used.
# Log-bin =
Only error logs are enabled. To enable other logs, remove the preceding.
Long_query_time = 1 -- indicates how long the SQL statement will be logged after execution. Here, it is 1 second.
Log-Slow-queries = slowqueris. log -- Records slow statements returned by the query.
Log-queries-not-using-indexes = nouseindex. log -- it is a literal meaning that the query with no index is used in the log.
Log = mylog. log -- Record all execution statements
Log-error = log-error.log
Log = log-query.log
Log-queries-not-using-Indexes
Log-warnings = 2
Log-Slow-queries = log-slow-query.log
Log-update = log-update.log
Long_query_time = 2
1. specify the recovery time syntax
If you accidentally cut down the data table of the database at this morning, you can use the following syntax to restore
mysqlbinlog -- stop-date = "8:59:59"/var/lib/MySQL/bin.000001 | mysql-u root-P
If you to restore the SQL syntax after 9:00:00, you can use
mysqlbinlog -- start-date = ""/var/lib/MySQL/bin.000001 | mysql-u root-P
or you want to restore the SQL syntax between and, the following syntax is the
mysqlbinlog -- start-date = "9:00:00" -- stop-date = "10:00:00"/var/lib/MySQL/bin.000001 | mysql- U root-P
In fact, you can also not execute, output SQL syntax to/tmp/restore first. SQL
mysqlbinlog -- start-date = "9:00:00" -- stop-date = "10:00:00"/var/lib/MySQL/bin.000001>/tmp/restore. SQL
Of course, you can also specify the database you want to output. The file is large
-- database = db_name,-D db_name
-- Host = host_name, -H host_name