Troubleshooting of MySQL database backup: Error 1005 (hy000) at line 12: Can't CREATE TABLE

Source: Internet
Author: User

You can back up Mysql Data in either of the following ways:
1) copy files. This is of course the simplest. Copy the folder of the corresponding database and then copy the file ibdata1.
2) mysqldump

Of course, the 2nd methods are better. For example, if I back up the database mydb, the steps are as follows:

MySQL/bin> mysqldump mydb> mydb. SQL

First, create a database in MySQL;

Create Database mydb;

Then Import mydb. SQL:

MySQL/bin> MySQL mydb <mydb. SQL

The error message is as follows:

Error 1005 (hy000) at line 12: Can't create table './mydb/Foo. frm' (errno: 150)

This is because the table has foreign key constraints.

......

I am not familiar with the database. As a result, Google and Baidu haven't seen a guide for database cainiao for half a day. Now, I have solved the problem and made a contribution to everyone: I am not talking nonsense :) the solution is:

Before restoring data,

Set foreign_key_checks = 0;

Set it back after recovery:

Set foreign_key_checks = 1

Click OK.

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.