Attempt to reply to a single table with an IDB file

Source: Internet
Author: User
Tags create index

Mysql> show engines;

Mysql> ALTER TABLE T1 engine = InnoDB;

Mysql> ALTER TABLE t7 auto_increment = 100;

Mysql> Show Table status like "T6" \G;


Try to reply to a single table with the IDB file, and note that you want to revert to the original library:

1. Back Up IBD files:

# CP T7.ibd T7.ibd.bak

2. Delete table data:

Mysql> SELECT * from T7;

+-----+------+

| I | name |

+-----+------+

| 1 | 1 |

| 2 | 2 |

| 3 | 3 |

| 6 | 1 |

| 7 | 2 |

| 8 | 3 |

| 100 | 1 |

| 101 | 2 |

| 102 | 3 |

+-----+------+

9 Rows in Set (0.00 sec)

Mysql> Delete from T7;

Query OK, 9 rows affected (0.07 sec)


Mysql> SELECT * from T7;

Empty Set (0.00 sec)

3. Correct identification of IBD files

Mysql> ALTER TABLE T7 discard Tablespace;


4. Reply to IBD files:

# MV T7.ibd.bak T7.IBD

# chown MySQL. T7.ibd

# chmod 660 T7.IBD


5. Correctly identify IBD files for manual replies

Mysql> ALTER TABLE T7 import tablespace;

Query OK, 0 rows affected, 1 warning (0.26 sec)


6. Query the data, lucky back!

Mysql> SELECT * from T7;

+-----+------+

| I | name |

+-----+------+

| 1 | 1 |

| 2 | 2 |

| 3 | 3 |

| 6 | 1 |

| 7 | 2 |

| 8 | 3 |

| 100 | 1 |

| 101 | 2 |

| 102 | 3 |

+-----+------+

9 Rows in Set (0.00 sec)


Mysql>


In-Memory database:

Mysql> CREATE TABLE T8 engine=memory select * from T7;

Mysql> Show Table status like ' T8 ' \g


Mysql> CREATE index Mem_hash using hash on T8 (i);

Query OK, 9 rows affected (0.03 sec)

Records:9 duplicates:0 warnings:0


Mysql> DROP index Mem_hash on T8;

Query OK, 9 rows affected (0.04 sec)

Records:9 duplicates:0 warnings:0


Mysql> CREATE index Mem_hash using Btree on T8 (i);

Query OK, 9 rows affected (0.03 sec)

Records:9 duplicates:0 warnings:0


Mysql> Show index from T8 \g




Attempt to reply to a single table with an IDB file

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.