All HowTo's MySQL & MariaDB

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.