How to fix the big guy called ‘ibdata1’

How to fix the big guy called ‘ibdata1’

The file ibdata1 is the system tablespace for InnoDB infrastructure, and it contains several informations about InnoDB such as table data pages, index pages, data dictionary, rollback segments, etc. This file is always growing, then, it’s easy to reach to giant sizes.

The size of this file commonly affects development and test machines, because many drops and imports with databases inflate this one. Then, to fix this problem, I have some steps to ends this problem.

Backup all your databases

Do a full dump of your databases.

Drop all your databases

Now, you’ll need remove all your databases, except for mysql and information_schema databases, because they are used by MySQL to control users and data information about managed databases.

Stop MySQL service

For the next step, you will need stop the MySQL service.

Configurations

Now, you’ll need change in MySQL how it’s manage InnoDB data, in this case using one file per table. Locate the my.cnf file on your server and putt this parameter at [mysqld] section:

Save with ‘Esc + :wq!’, then go to MySQL data folder:

The ls -alh command in this folder will print something like this:

Delete this file:

Finally, start MySQL service and import your databases again:

Blog Databases Linux