Today I checked that the server disk was almost full, so I looked for the reason. Two reasons were found;
1. There are many and large mysql-bin.000001 files;
mysql> reset master;
Run the above command to clear the log;
2. The MySQL directory ibdata1 file is too large;
1. Back up the data in the database.
mysqldump -u root -p --extended-insert --all-databases --add-drop-database --disable-keys --flush-privileges --quick --routines --triggers > /home/all-database.sql //有的文档用的是这样的参数: mysqldump -q -uroot -p --add-drop-table --all-databases --events >/home/all-database.sql
If ibdata1 is hundreds of GB, the backup process may take several hours.
2. Stop the MySQL service.
service mysql stop
3. Delete ibdata1, ib_logfile* and other files
mv ibdata1 ibdata1.20160419 mv ib_logfile0 ib_logfile0.20160420 mv ib_logfile1 ib_logfile1.20160420
4. Modify the my.cnf configuration file
vi /etc/mysql/my.cnf
In [mysqld ] Add the following configuration under the subkey:
innodb_file_per_table = 1
6. Restart the MySQL service
service mysql start ps -ef|grep mysql
7. Restore data (re-import data)
mysql -u root -p Enter password: source /home/all-databaes.sql