# How to decrease disk space occupied by /var/lib/mysql?

**URL:** <https://forums.percona.com/t/how-to-decrease-disk-space-occupied-by-var-lib-mysql/7263>\
**Category:** Other MySQL® Questions\
**Created:** [October 25, 2019, 8:09am UTC](https://forums.percona.com/t/how-to-decrease-disk-space-occupied-by-var-lib-mysql/7263 "2019-10-25T08:09:50Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Rick\_James](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Rick\_James](https://forums.percona.com/u/Rick_James)\
**Post date:** [March 22, 2020, 5:46pm UTC](https://forums.percona.com/t/how-to-decrease-disk-space-occupied-by-var-lib-mysql/7263/3 "2020-03-22T17:46:17Z")

</div>

Tablespaces do not give space back to the OS. Deleted rows simply leave free space in the tablespace.

If the tables were generated while innodb\_file\_per\_table was ON, then do SHOW TABLE STATUS to see which ones have more than a few MB of “Data\_free”. For those, do OPTIMIZE TABLE. (Start with the smallest).

If all the tables were built with OFF, you are in a bad situation. The standard fix is to take a full dump, clear the disk (consider upgrading mysql at the same time), and reload everything. This time have innodb\_file\_per\_table=ON before starting.

---

_[View the full topic](https://forums.percona.com/t/how-to-decrease-disk-space-occupied-by-var-lib-mysql/7263)._
