All Linux HowTo's

How To Purge Old MySQL Data And Recover Disk Sapce

This article demonstrates how to delete old data from a MySQL table and recover the disk space from the removed data. This works with MYISAM databases.

USE mydatabase;
DELETE FROM mytable WHERE time < NOW() - INTERVAL 1 WEEK;

The above will remove anything older than 1 week. We're relying on there being a column with the date-time format.

OPTIMIZE TABLE mytable;

The above will reclaim the disk space.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.