The Innodb database only marks deleted data and does not actually release the occupied disk space, which leads to the increasing number of InnoDB database files. If you want to completely release the deleted data, you need to export the database, delete the InnoDB database file, and then import it. The basic steps are as follows:
1. Use the mysqldump command to export the InnoDB Database
2. Stop MySQL
3. Delete All InnoDB database files and logs
4. Start MySQL and automatically recreate InnoDB database files and log files
5. Import the database files backed up earlier.
Note that you have configured MySQL database replication. When you import database backup files, all queries may be written to Binlog. You can run SET SQL _LOG_BIN = 0; stop writing Binlog temporarily.
Another way is to set innodb_file_per_table when creating a database. In this way, InnoDB creates a data file for each table, then, you only need to run the optimize table * command to release all the deleted disk space.