Mysql InnoDB How to free disk space after deleting data _mysql

Source: Internet
Author: User

The InnoDB database is marked as deleted and does not really release the disk space it occupies, which results in a growing InnoDB database file.

If you set up innodb_file_per_table=1 when you create the database, InnoDB creates a data file for each table and then only needs to run the Optimize table command to free up all the deleted disk space.

After running the Optimize table name, it will eventually report the table does not support optimize, doing recreate + analyze instead, but it has actually succeeded:)

-------------------------------------------------------------

If you do not set this parameter, and want to free space, completely release the deleted data, you need to export the database, delete the InnoDB database files, and then poured.

The following are the basic steps:

1 Exporting the InnoDB database using the mysqldump command

2 Stop MySQL

3 Delete all InnoDB database files and logs

4 start MySQL and automatically rebuild InnoDB database files and log files

5 Importing database files that were previously backed up

----------------------------------------------

Specific commands:

Copy Code code as follows:

# BACKUP DATABASE:

Mysqldump-uroot-proot--quick--force--all-databases > Mysqldump.sql
# Stop Database

Service Mysqld Stop
# Delete these large files
Rm/usr/local/mysql/var/ibdata1
rm/usr/local/mysql/var/ib_logfile*
# Manually delete all database folders except MySQL, and then start the database

Service mysqld Start
# Restore Data

Mysql-uroot-proot < Mysqldump.sql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.