MySQL log cleanup

Source: Internet
Author: User
Tags log log

MySQL bin-log log cleanup


Bin-log log files found in MySQL database directory are very large

[Email protected] var]#du-SHmysql-bin* |Sort1020K MySQL-bin.0000021.1G Mysql-bin.0000211.1MMysql-bin.000018136K MySQL-bin.000019172K MySQL-bin.000014191M MySQL-bin.000013224M MySQL-bin.00001728K MySQL-bin.0000013.5MMysql-bin.0000124.0K Mysql-bin.0000034.0K Mysql-bin.0000044.0K Mysql-bin.0000054.0K Mysql-bin.0000064.0K Mysql-bin.0000074.0K Mysql-bin.0000154.0K Mysql-bin.0000164.0K mysql-Bin.index5.5MMysql-bin.00001163M MySQL-bin.00000864K MySQL-bin.00000965M MySQL-bin.00002272K MySQL-bin.000010863M MySQL-bin.000020[[email protected] var] #登陆到mysql查看bin-Logmysql>show binary logs;+------------------+------------+| Log_name | File_size |+------------------+------------+| Mysql-bin.000001|27338|| Mysql-bin.000002|1038693|| Mysql-bin.000003|1272|| Mysql-bin.000004|126|| Mysql-bin.000005|126|| Mysql-bin.000006|126|| Mysql-bin.000007|126|| Mysql-bin.000008|64950073|| Mysql-bin.000009|57911|| Mysql-bin.000010|69548|| Mysql-bin.000011|5735460|| Mysql-bin.000012|3564763|| Mysql-bin.000013|199226556|| Mysql-bin.000014|170872|| Mysql-bin.000015|838|| Mysql-bin.000016|126|| Mysql-bin.000017|233747353|| Mysql-bin.000018|1128493|| Mysql-bin.000019|133652|| Mysql-bin.000020|903932814|| Mysql-bin.000021|1073745163|| Mysql-bin.000022|67963674|+------------------+------------+ ARowsinchSet (0.00sec) MySQL>


Delete the logs before 2014-06-01 00:01:01:

' 2014-06-01 00:01:01 ' ;    0 rows affected (0.21  sec) MySQL



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Keep Last Bin-logs

Mysql> PURGE BINARY LOGS to'mysql-bin.000022'; Query OK,0Rows Affected (0.60sec) MySQL>MySQL>MySQL>MySQL>MySQL>MySQL>show binary logs; +------------------+-----------+| Log_name | File_size |+------------------+-----------+| Mysql-bin.000022|68830784|+------------------+-----------+1RowinchSet (0.00sec) MySQL>






Related Article

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.