In the MySQL database, if you do not specify the innodb_file_per_table parameter to separate the data for each table, the MySQL data will be stored in the Ibdata1 file.
MySQL ibdata1 storage data, indexes, etc., is the most important data source of MySQL.
As data grows, ibdata1 stores more and more data, and the corresponding volume becomes larger. And depressed, when you delete some data, the volume of ibdata1 is not reduced. Wasted disk space, affecting the I/O performance of the disk.
Here's how to reduce the volume of ibdata1
1. Backing Up the database
No matter what changes are made, it is always a good habit to back up first.
Suppose I have a database ' leon_database '
- - - > / Backup path /Leon_database.sql
2. Delete Database
Drop table leon_database;
3. Delete ibdata1 files and ib_logfile* files
4, create a new database leon_database, and import the backup good/backup path/leon_database.sql
- - < / Backup path /leon_database.sql;
4.5. If you want to use a stand-alone table space, you can add a row in MY.CNF (the path is generally/etc/my.cnf), or skip this step if you don't want to.
= 1 #1表示开启, 0 indicates off
5. Restart the MySQL service.
Service mysqld Restart
MySQL optimized ibdata1 size