1. First confirm that your log is enabled
Mysql>show variables like ' log_bin ';
If enabled, that is, the log file is in the MySQL installation directory in the data directory
2. How to know the current log
Mysql> Show master status;
3. See binary log file with Mysqlbinlog
Shell>mysqlbinlog mail-bin.000001
Or
Shell>mysqlbinlog mail-bin.000001 | Tail
4. Correct removal of MySQL Bin-log log practice
In MySQL will be a large number of such as mysq-bin.000001 such log files, these are binary files, if we are ordinary log without master-slave configuration can be directly used reset Master to delete this method is very simple,
If there is no master-slave replication, you can reset the database log by resetting master, clearing the previous log file:
There is also a my.cnf in the configuration.
The number of days that the binary log is automatically deleted. This set the automatic purge 3 days ago of the logs.
The default value is 0, which means "no automatic deletion".
Cases
# by file: Delete mysql-bin.000354 before the log, does not contain mysql-bin.000354
mysql>purge binary logs to ' mysql-bin.000354 ';
Query OK, 0 rows affected (0.16 sec)
# by Time: Delete logs before 00:00:00
mysql>purge binary logs before ' 2011-11- Ten 00:00:00 ';
# by Time: Please three days before the log
mysql> purge master logs before date_sub (now (), Interval 3 day);
Automatic cleanup log:
# Modify MY.CNF file configuration Bin-log expiration
expire-logs-days=7
max-binlog-size=268435456
If you are the master and slave MySQL log file please refer to the following method
Before deleting the log, check the log files currently used by the master/slave server,
///first log on to the server that you want to delete log MySQL terminal
#mysql-u root-pxxxxx
//Check replication master server status
mysql> Show Master Status
+------------------+-----------+--------------+----------------------------------------+
| File | Position | binlog_do_db | binlog_ignore_db |
+------------------+-----------+--------------+----------------------------------------+
| mysql-bin.000097 | 541677824 | www | test,mysql,information_schema |
+------------------+-----------+--------------+----------------------------------------+
//Copy the log file currently in use by the primary server is : mysql-bin.000097//
Check replication from server state
mysql>show slave statusg
//Copy primary server log files currently in use from the server are: mysql-bin.000103
//The log file currently in use is 000097, what I need to do is delete all the logs before No. 00095 (reserve out the log for the last few days)
Mysql>purge master logs to ' mysql-bin.000095;
#ll/usr/local/mysql/var/
//From the results, all logs prior to number 000097 have been deleted