Downsize the mysqlibdata1 file-release disk space

Source: Internet
Author: User
How to narrow down the mysqlibdata1 file and release disk space? The mysqlibdata1 file stores data and indexes. If the data in the database is not stored separately, the size of the file will easily be GB or even dozens of GB. It is not suitable for some servers with small applications and disks. Therefore, we need to shrink this file.

How to narrow down the mysql ibdata1 file and release the disk space? Mysql ibdata1 files store data and indexes. If the data in the database is not stored separately, the size of the file will easily be GB or even dozens of GB. It is not suitable for some servers with small applications and disks. Therefore, we need to shrink this file.

Shrink mysql ibdata1 file-release disk space

?

Mysql ibdata1 files store data and indexes.

If the data in the database is not stored separately, the size of the file will easily be GB or even dozens of GB. It is not suitable for some servers with small applications and disks. Therefore, we need to narrow down this file.

Method: Separate data files.

?

See: http://dev.mysql.com/doc/refman/5.1/zh/database-administration.html#backup

?

Steps:

1. Back up the database

Enter MySQL Server 5.5/bin from the command line
Back up all databases and run the command mysqldump-q-uusername-pyourpassword -- add-drop-table -- all-databases>/all. SQL.

After this step, stop the database service.

2. Modify the mysql configuration file

Modify the my. ini file and add the following Configuration:

Iinnodb_file_per_table = 1

Use a separate innoDB file for each table to modify the/etc/my. cnf File

3. Delete the original data file

Delete the original ibdata1 file and Log File ib_logfile *, and delete the application database folder under the data Directory (do not delete the mysql folder)

4. Restore the database

Start Database Service

Enter MySQL Server 5.5/bin from the command line
Restore all databases and run mysql-uusername-pyourpassword. </all. SQL

After the preceding steps, we can see that the new ibdata1 file is only dozens of MB, and the data and indexes are converted into small ibd files for a single table, they are in the folder of the corresponding database.

?

Note: at present, there is no way to directly reduce the size of the ibdata file without exporting data and importing it again. For databases with bad paths and corrupted tablespace in ibdata files, you can only skip the damaged id, dump the data into an SQL file, and then import it.

?

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.