MySQL ibdata1 takes up space for large free MySQL ibdata1 files

Source: Internet
Author: User

MySQL ibdata1 takes up space for large free MySQL ibdata1 files


Background: A recent company server alarm, disk space alarm super threshold. Originally MySQL database Data directory is particularly large, the previous article describes the change MySQL data files directory, this article mainly describes how to put the space occupied by MySQL released.



Description: MySQL has a variety of storage engines, such as MyISAM,InnoDB are very common. If you use the InnoDB, and the MySQL default configuration file, MySQL data will be stored in the Ibdata1 file, after a period of time this file will become very large, consuming a lot of disk space. How to release the space occupied by MySQL.


MySQL ibdata1 store data, indexes, etc., is the most important data of MySQL.

Steps:

1, backing up the database

Back up all databases, execute commands mysqldump-uusername-ppassword--all-databases >/backup/all.sql or just back up the required libraries.



Deleting a database
Drop database A;
Drop database B;



Stop database: Service mysqld stop


2. Modify the MySQL configuration file

Modify the My.cnf file to add the following configuration

Innodb_file_per_table

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*, delete the application database folder under the Data directory (Mysql,test,information_schema the database itself folder do not delete)


4. Restore the database

Start the Database Services service mysqld start

Restore all databases, execute command mysql-uusername-ppassword <all.sql



After these steps, you can see that the new Ibdata1 file is only dozens of M, and the data and indexes become small IBD files for a single table, which are under the folder of the corresponding database.


This article is from the "Technical Achievement Dream" blog, please be sure to keep this source http://pizibaidu.blog.51cto.com/1361909/1697016

MySQL ibdata1 takes up space for large free MySQL ibdata1 files

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.