MySQL separately stores the table space Innodb_file_per_table.

Source: Internet
Author: User

MySQL can use multiple engines. When we choose to use the InnoDB engine, the ibdata1 file will become larger and larger over time, occupying a large amount of disk space.

So what are stored in ibdata1 and why are they getting bigger and bigger? First, let's check the ibdata1 structure. ibdata1 is a common tablespace of InnoDB. By default, it stores all tablespaces in ibdata1. Therefore, the infinite growth of ibdata1 files requires release.

The Innodb_file_per_table parameter of MySQL controls the storage mode of tablespaces. By configuring the Innodb_file_per_table parameter, you can store all tablespaces in ibdata1 instead of using exclusive tablespaces to separately store tablespaces.

The following describes the specific operations.

1) export all data in the database

# Mysqldump-u root-p -- all-database & gt;/tmp/all-database.dump

2) delete data in the database

# Mysql-u root-p
Mysql> drop database dbname;
3) Stop MySQL

# Service mysqld stop

4) delete the ibdata1 file

# Mv/var/lib/mysql/ibdata1/tmp
# Mv/var/lib/mysql/ib_logfile0/tmp
# Mv/var/lib/mysql/ib_logfile1/tmp
5) configure innodb_file_per_table

# Vi/etc/my. cnf
Innodb_data_home_dir =/var/lib/mysql
Innodb_data_file_path = ibdata1: 1G; ibdata2: 200 M: autoextend
Innodb_file_per_table

Enable exclusive tablespace, and specify the size of ibdata1 to 1 GB, and the size of ibdata2 to 200 MB, which is automatically expanded.

6) start MySQL


# Service mysqld start

7) import data

Import the exported database to the database.

# Mysql-u root-p </tmp/all-database.dump

When the exclusive tablespace is enabled, ibdata1 is not required because the following data is stored in ibdata1.

Metadata of the InnoDB table
Buffer
UNDO log

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.