2 ways to InnoDB MySQL MyISAM

Source: Internet
Author: User
Tags mysql backup

2 ways to InnoDB MySQL MyISAM

What is the difference between MyISAM and InnoDB in MySQL? One is like a convenience store, one is like a big shopping mall, they exist to adapt to different occasions. When the traffic is small, we can use MyISAM, when the traffic is large, we may be in the database, all the table or part of the table into InnoDB. Here are 2 practical ways to accomplish this conversion.

One, use ALTER TABLE to achieve.

    1. mysql> ALTER TABLE merchant Engine=innodb;

The conversion method is simple. The MyISAM has three files stored on the disk. MYD,. Myi,.frm file, will the three files not disappear after conversion? Does the shared tablespace or stand-alone table space in InnoDB not increase?

    1. [[email protected] test]# ls |grep merhcant|xargs-i du {}
    2. Merchant.frm
    3. 690 Merchant. MYD
    4. 144 Merchant. MYI

Above is the file size before conversion, after conversion. MYD,. The myi disappeared. The InnoDB shared table space is increased by 8M.

    1. [[email protected] data]# ls |grep ibdata |xargs-i du-m {}
    2. Ten ibdata1 //Pre-conversion
    3. [[email protected] data]# ls |grep ibdata |xargs-i du-m {}
    4. Ibdata1 //converted

MySQL tables are stored on disk in a way that does not need to be converted. this is more convenient. InnoDB Here I set a shared table space, the size of the converted table is not more than 1M, but the shared table space automatically increased 8M, so the size of the shared table space, not according to the size of the table to increase, there is a base. We can set it through Innodb_autoextend_increment.

Second, export the data, re-build the table

1, export table structure and data, delete cousin, re-build table

  1. In Method 1, we can copy the SQL that created the table and replace it with Engine=myisam, Engine=innodb
  2. Mysql> Show CREATE TABLE merchant\g;
  3. 1. Row ***************************
  4. Table:merchant
  5. Create table:create Table ' merchant ' (
  6. ' Btid ' int (5) unsigned zerofill not NULL auto_increment,
  7. ' Btname ' varchar (+) not NULL,
  8. ' Btnote ' text,
  9. PRIMARY KEY (' Btid '),
  10. UNIQUE KEY ' btname ' (' Btname ')
  11. ) Engine=myisam DEFAULT Charset=utf8
  12. 1 row in Set (0.00 sec)
  13. Method 2, directly export the table structure, replace a myisam in the file
  14. Mysqldump-udba-p-D test Merchant >/tmp/test/mytest/merchant.sql;

2. Exporting data

    1. Mysqldump-udba-p--no-create-info test Merchant >/tmp/test/mytest/merchant_data.sql;

3, delete cousin, re-build table, import data, this will not say ,linux simple MySQL backup and import, as well as file backup and import

2 ways to InnoDB MySQL MyISAM

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.