Export Mysql database with foreign keys

Asked

Viewed 115 times

1

My hosting uses phpMyAdmin to manage the bank and does not allow the remote connection because it is a free plan.

I need to export my base to the hosting, generated the . sql file with the command mysqldump -h host -u user -p base --routines > base.sql, but after putting the . sql file in the hosting, all foreign keys were lost.

There’s another way to make sure it doesn’t happen?

I appreciate the help.

  • Basically you want a command that gives you the dump with the foreign keys together?

  • Exactly, I think that this must be a problem in the lodging, for being a free plan, since in my machine I made a test and the keys came.

  • I find it very difficult that it is something that the hosting has done on purpose, because it doesn’t make sense and they would have to forge a version of Mysql for that purpose only, which there is no reason to do. However, I have a better guess: Your hosting tables are with Myisam or as Innodb? What is the version of Mysql there?

  • In the lodging this Myisam and version 5.1, and in my machine Innodb.

1 answer

2


Myisam has no foreign keys and does not impose referential integrity. That means you can’t pull foreign keys from your database simply because they’re not even there.

  • 1

    Gee! I didn’t know that, I’ll look for another lodging. Thanks for the help Victor.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.