InnoDB databases in MySQL are stored in one huge file by default. This file does not release used space when you delete tables. If you are developing a database and make frequent changes to the structure, you will quickly notice that the size of this file is much larger than all of your databases combined. The file is called ibdata1.
So what can you do about it? MySQL allows you to store InnoDB databases on a file-per-table basis. Here's how you do it:
- dump all databases, sprocs, triggers, etc (you need to restore them after)
- DROP all databases (except phpmyadmin or other system DBs)
- /etc/init.d/mysql stop (stop MySQL server)
- nano /etc/mysql/my.cnf (edit the MySQL configuration file, add this line)
[mysqld]
innodb_file_per_table=1 - rm /var/lib/mysql/ibdata1 (delete ibdata1 and ib_log files)
- /etc/init.d/mysql/start (Start MySQL server)
- restore dbs from dump (Now all databases will be split into many files)
No comments:
Post a Comment