MySql Log clearing

Source: Internet
Author: User
If you want to disable binary mysql logs, you can. ini to the log-bin line comment out to clear the binary log, in mysql enabled the binary log state, log on to mysql as root after executing one of the following two commands: PURGEMASTERLOGSbefore2020-1-1; PURGEMASTER

If you want to disable binary mysql logs, you can. in ini, comment out the log-bin line to clear binary logs. when mysql enables binary logs, log on to mysql as the root user and execute one of the following two commands: purge master logs before '2017-1-1 '; PURGE MASTER

If you want to disable binary mysql logs, you can. in ini, comment out the log-bin line to clear binary logs. when mysql enables binary logs, log on to mysql as the root user and execute one of the following two commands:


Purge master logs before '2017-1-1 '; PURGE binary LOGS before the specified date purge master logs to 'mysql-bin.000020'; purge master logs before the specified file number

Today, I read the MySql Log, Which is 3.5 GB and occupies space. I cleared it ~..


root@xss:/usr/local/mysql/var# ls -liahtotal 3.5G57153761 drwx------  4 mysql mysql 4.0K Mar 12 17:28 .57147488 drwxr-xr-x 11 root  mysql 4.0K Jan 31 14:31 ..57158026 -rw-rw----  1 mysql mysql 5.0M Mar 12 17:28 ib_logfile057158038 -rw-rw----  1 mysql mysql 5.0M Mar  6 12:36 ib_logfile157156045 -rw-rw----  1 mysql mysql  10M Mar 12 17:26 ibdata157153762 drwx------  2 mysql mysql 4.0K Feb  1 13:06 mysql57153766 -rw-rw----  1 mysql mysql  19K Jan 31 14:31 mysql-bin.00000157153836 -rw-rw----  1 mysql mysql 718K Jan 31 14:31 mysql-bin.00000257153838 -rw-rw----  1 mysql mysql  865 Jan 31 14:31 mysql-bin.00000357153837 -rw-rw----  1 mysql mysql  125 Jan 31 14:31 mysql-bin.00000457154285 -rw-rw----  1 mysql mysql  125 Jan 31 15:10 mysql-bin.00000557154295 -rw-rw----  1 mysql mysql  125 Feb  1 03:01 mysql-bin.00000657171378 -rw-rw----  1 mysql mysql 377M Feb  1 11:39 mysql-bin.00000757154853 -rw-rw----  1 mysql mysql  20K Feb  1 13:01 mysql-bin.00000857153937 -rw-rw----  1 mysql mysql 378M Feb  1 13:08 mysql-bin.00000957154819 -rw-rw----  1 mysql mysql  11M Feb  1 15:04 mysql-bin.00001057154283 -rw-rw----  1 mysql mysql 303M Feb  4 16:48 mysql-bin.00001157156109 -rw-rw----  1 mysql mysql 1.1G Feb 15 23:23 mysql-bin.00001257156229 -rw-rw----  1 mysql mysql 517M Feb 23 10:55 mysql-bin.00001357158984 -rw-rw----  1 mysql mysql 318M Feb 27 14:23 mysql-bin.00001457158040 -rw-rw----  1 mysql mysql 269K Feb 27 14:26 mysql-bin.00001557158042 -rw-rw----  1 mysql mysql 290M Mar  3 04:22 mysql-bin.00001657158070 -rw-rw----  1 mysql mysql 133M Mar  4 09:44 mysql-bin.00001757164854 -rw-rw----  1 mysql mysql  71M Mar  5 22:18 mysql-bin.00001857164965 -rw-rw----  1 mysql mysql  498 Mar  5 22:18 mysql-bin.00001957164967 -rw-rw----  1 mysql mysql  106 Mar  5 22:18 mysql-bin.00002057164977 -rw-rw----  1 mysql mysql  106 Mar  5 22:18 mysql-bin.00002157164978 -rw-rw----  1 mysql mysql  106 Mar  5 22:18 mysql-bin.00002257164979 -rw-rw----  1 mysql mysql  106 Mar  5 22:18 mysql-bin.00002357164980 -rw-rw----  1 mysql mysql  106 Mar  5 22:18 mysql-bin.00002457164981 -rw-rw----  1 mysql mysql  106 Mar  5 22:18 mysql-bin.00002557164982 -rw-rw----  1 mysql mysql 7.7K Mar  5 22:18 mysql-bin.00002657158115 -rw-rw----  1 mysql mysql 4.3M Mar  6 14:39 mysql-bin.00002757158073 -rw-rw----  1 mysql mysql  24M Mar  6 23:46 mysql-bin.00002857164848 -rw-rw----  1 mysql mysql  93M Mar  8 18:03 mysql-bin.00002957153914 -rw-rw----  1 mysql mysql 8.9M Mar  8 22:05 mysql-bin.00003057158178 -rw-rw----  1 mysql mysql 5.6M Mar 11 12:16 mysql-bin.00003157158151 -rw-rw----  1 mysql mysql 164K Mar 12 17:22 mysql-bin.00003257158175 -rw-rw----  1 mysql mysql  712 Mar 12 17:26 mysql-bin.00003357153942 -rw-rw----  1 mysql mysql  106 Mar 12 17:28 mysql-bin.00003457153764 -rw-rw----  1 mysql mysql  646 Mar 12 17:28 mysql-bin.index57154807 drwx------  2 mysql mysql 4.0K Feb  1 13:06 xss57153835 -rw-rw----  1 mysql root  3.2K Mar 12 17:28 xss.err57153915 -rw-rw----  1 mysql mysql    4 Mar 12 17:28 xss.pid

The last log number is 000034. The command is as follows:


mysql> PURGE MASTER LOGS TO 'mysql-bin.034'; ERROR 1373 (HY000): Target log not found in binlog indexmysql> PURGE MASTER LOGS TO 'mysql-bin.000034'; Query OK, 0 rows affected (0.53 sec)

Then look at the directory in ls:


root@xss:/usr/local/mysql/var# ls -liahtotal 21M57153761 drwx------  4 mysql mysql 4.0K Mar 12 17:31 .57147488 drwxr-xr-x 11 root  mysql 4.0K Jan 31 14:31 ..57158026 -rw-rw----  1 mysql mysql 5.0M Mar 12 17:28 ib_logfile057158038 -rw-rw----  1 mysql mysql 5.0M Mar  6 12:36 ib_logfile157156045 -rw-rw----  1 mysql mysql  10M Mar 12 17:26 ibdata157153762 drwx------  2 mysql mysql 4.0K Feb  1 13:06 mysql57153942 -rw-rw----  1 mysql mysql  106 Mar 12 17:28 mysql-bin.00003457153764 -rw-rw----  1 mysql mysql   19 Mar 12 17:31 mysql-bin.index57154807 drwx------  2 mysql mysql 4.0K Feb  1 13:06 xss57153835 -rw-rw----  1 mysql root  3.3K Mar 12 17:31 xss.err57153915 -rw-rw----  1 mysql mysql    4 Mar 12 17:28 xss.pid

Cleared, with 000034 remaining.

Original article address: Clear MySql logs. Thank you for sharing it with the original author.

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.