I have a mysql DB configured with the innoDB storage engine.
I dropped the database (drop database <dbname>
)
but the disk space hasn't be liberated.
At /var/lib/mysql
there are some "big" files called ib_logfile0
, ib_logfile1
and ibdata1
where the last one is really big. I pressume that these files are in fact the original DB.
How can I know if I can delete them. Or a better question is how to drop a database so that the disk space is reclaimed.
Clarification
I want to drop the complete database and free the disk space.
I don't want to perform any restore.
Thanks in advance.
The ability to truncate tables and return disk space to the operating system also means that physical backups can be smaller. Truncating tables that are stored in the system tablespace (tables created when innodb_file_per_table=OFF ) or in a general tablespace leaves blocks of unused space in the tablespace.
Tables that use the InnoDB storage engine are written to disk in data files called tablespaces. An individual tablespace can contain data from one or more InnoDB tables as well as the associated indexes.
Unfortunately there is no way to shrink these files once the space has been allocated. MySQL will however re-use the space when new data is added, but the file won't shrink.
To shrink the size you will need to dump the databases and then restore them again.
You can also do the following:
Set innodb_file_per_table in your config file, which will create a separate file per table. That will then allow you to delete these files once a database is dropped and also allow you to use the OPTIMIZE TABLE command to rebuild ibd files if you shrink the data in a particular table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With