While dealing with large data, I realised ibdata file was rapidly increasing. I did some research and found out ibdata1 not shrinking is a particularly annoying feature of MySQL. The ibdata1 file can´t actually be shrunk unless you delete all databases, remove the files and reload a dump.
Here are the steps for doing so:
Thats it!
Here are the steps for doing so:
- Do a mysqldump of all databases, procedures, triggers etc except the mysql and performance_schema databases
mysqldump -u [username] -p[root_password] [database_name] > dumpfilename.sql
- Drop all databases except the above 2 databases
(in MySQL console) DROP DATABASE [database_name]
- Stop mysql
sudo service mysql stop sudo service mariadb stop
- Delete ibdata1 and ib_log files
sudo rm /var/lib/mysql/ibdata1 sudo rm /var/lib/mysql/ib_logfile
- Start mysql
sudo service mysql start sudo service mariadb start
- Restore from dump
(in MySQL console) create database [database_name] mysql -u [username]-p[root_password] [database_name] < dumpfilename.sql
Thats it!
No comments:
Post a Comment