How to import foreign key constraints to InnoDB tables - mysql

I have my local MySQL database set to use the InnoDB engine by default. The database holds about 30 tables, all InnoDB.
However, when I ran the migrations to create the same database on a remote server, it had MyISAM as the default, and it created all the tables in MyISAM.
Since MyISAM doesn't support foreign keys the way InnoDB does, they were all lost in the process. Now I've changed all the tables on the remote server to InnoDB manually.
What is the best/quickest way to import just the foreign key constraints from the local to the remote database now? I can go one table at a time and add them all, but I was wondering if there's a better way.
Dumping the remote database and then rebuilding it is not an option at this point.

Related

MariaDB logical backup restores partially

I am new to mariadb.
I am using mysqldump to backup the database. Backup works perfectly but when I tried to restore the backup it's giving errors.
What I observed is while backing up it's sequentially backups the tabels.
While restoring if a table has foreign key dependency and it comes first in the order, backup terminates there itself.
How can backup and restore without failing.
UPDATE
I found the answer here
Backup MySQL schema with foreign key table constraints

MySQL InnoDB foreign key remotely between different databases

I am interested in referencing a table (InnoDB in MySQL) with foreign key that references another table in a different database noton the same machine.
The two MySQL servers with the two databases are on the same network and can be reached remotely from one another.
Is this a set-up possible? If so, how can it be done?

Can not able to set foreign key in mysql db using SqlYog

Getting error while setting foreign key to table as shown in image.
Database Version: MySql 5.6
Change Engine to InnoDB
Check the difference between MyISAM and InnoDB here to make suitable decision for your database design
What are the main differences between InnoDB and MyISAM?
MyISAM versus InnoDB
What's the difference between MyISAM and InnoDB?

mysql - backing up related innodb databases

I have a question relating to the backing up of multiple MySQL innodb databases which have cross database relations with one another. A concern would be the relational integrity of the data during backup and restore of the databases.
The use case for this would be a situation where one "master" database is been used to hold top level data such as User information for multiple separate domains which cannot be consolidated into one database. Setting this up is not an issue as MySQL allows cross database relations with innodb foreign keys.
However, how would one properly back up the master and secondary databases (assuming they are on the same server) without breaking the foreign keys during back up.
I am looking for a way to some how capture a "snap shot" in time of those databases in that instant or if that is not possible to preserve the relations during backup time...
I hope I understand the question correctly.
Suppose you have two databases (db1 and db2) where a foreign key constraint from one or more tables in db2 references something in db1.
If you want to make sure everything is point-in-time consistent when making a backup, you can let mysqldump do it for you. Whenever you run mysqldump, you issue the --single-transaction option like this:
mysqldump -u... -p... --single-transaction --databases db1 db2 > db1_db2.sql
An internal checkpoint is created so that db1 and db2 are consistent in terms of referential integrity and in point-in-time EVEN IF DATA IS BEING ENTERED INTO db1 AND db2 DURING THE BACKUP.
During the restore of a mysqldump, foreign keys are disabled to allow a clean, fast reload reload. You can trust the foreign keys being disabled during restore IF AND ONLY IF the mysqldump was made using the --single-transaction option.

InnoDB restore database is very slow

I have Mysql installed version 5.1.49-1ubuntu8.1 (with default InnoDB without any modification)
When using InnoDB, the mysqldump and read performance is comparable to MyISAM, but restore database is very slow.
When trying to install Drupal on blank database also take too long
Other than default-storage-engine = innodb, Is there anything I need to do before use InnoDB?
You should disable keys on the tables while restoring. This is the default behavior with the dumps generated from mysqldump. What is the command line you are using for dumping data?
You should dump the tables in the order of the primary key.