I recently had a 8GB ibdata1 file in /var/lib/mysql
because one of my databases previously got spammed by 8GB worth of data. I deleted that spammed database, and running the following query in MySQL terminal
SELECT table_schema "Database Name", sum( data_length + index_length ) / 1024 / 1024 "Database Size in MB" FROM information_schema.TABLES GROUP BY table_schema;
yielded 100MB worth of combined data in my database. However my ibdata1 file was still a hefty 8GB. So then I followed the instructions of the accepted answer here to regenerate my ibdata1 and log files:
How to shrink/purge ibdata1 file in MySQL
This worked.
However, as soon as I reboot my Linux server, many of the databases (but not all) in my MySQL server suddenly have zero data. I repeated the instructions in the accepted answer with and without innodb_file_per_table
in the appropriate place in my my.conf
file, but it still doesn't prevent the destruction of MySQL databases after a Linux reboot. I notice that my ibdata1 file never exceeds 10MB anymore.
Right now, I've re-imported all my databases, and although things are working, i'm worried about losing all my data the moment the server needs to reboot.
Why is this happening? How do I prevent the destruction of MySQL databases after a Linux server reboot?