First of all, why do this because I work on a large Drupal project, the database files are large, and each new feature is developed on the branch, which means I need to build multiple local environments and often need to delete old branches and create new branches.
Since the database uses most of the InnoDB engine, and InnoDB is not released after the space is allocated, it can not be reused (this may be the way I haven't found the right method), so because of my frequent database creation and deletion, InnoDB's database files are getting bigger and larger. So decided to give the database file thin body.
The InnoDB database file defaults to the public ibdata1, which has reached 17G in my locality and is still getting bigger.
Below is the slimming step, pay attention to the original IBDATA1 files before the backup.
1, delete unwanted databases from the command line or phpMyAdmin.
2, back up all the databases:
Mysqldump-udbuser-ppassword--quick--force--routines--add-drop-database--all-databases--add-drop-table >/your _backup_place/mysqldump.sql
This is mainly to look at the following optional parameters, this operation is a backup of all the database, if the local database more, it will be slow. Of course, when the import will be more slow, I was in order to save space for it, if you have the same ideas as me, the use of this article's program consequences.
3, delete the Ibdata1 file, the import will be automatically established. The rest of the database is not a pipe, because the import will be deleted before the build.
4, enter the MySQL command line to import using the source command.
In the end, whether or not everyone succeeds, I am successful anyway. :)