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?
Related
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.
In our project we are planning to introduce MySQL NDB cluster to have 99% uptime for our multiple applications dependent on MySQL.
So MySQL is being deployed in two machines. In both the machines Data Node, Management Server and SQL node is deployed and configured to form a cluster as shown in the below snippet.
Based on my understanding replication of data will be done for the data stored in Data Nodes. But can we restrict the replication only to a set of tables or database?
Reason for this query is, there are two applications that are dependent on MySQL, where only one application needs this replication and the other doesn't need this feature because it should connect to a standalone instance of MySQL to store it's local data which shouldn't be replicated as it would cause problem to the application running in another machine.
Please share your thoughts on this.
Though we have deployed MySQL NDB Cluster, the mysqld still supports INNODB storage type. So in order to achieve the above requested need, we created tables explicitly with Storage Engine by mentioning in CREATE TABLE statement like below. This overrode the storage configuration mentioned in my.cnf.
CREATE TABLE IF NOT EXISTS `CDS` (
`CD_ID` bigint(20) NOT NULL,
PRIMARY KEY (`CD_ID`)
) ENGINE=innodb
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
I wonder if someone could help me with a small problem…I’m setting up my server with alwaysOn and I’ve added the SSIS catalog in the availability group. When I failover, it works but I need to run a command to re-encrypt the Master Key on the failover node:
Alter Master Key Add encryption by Service Master Key
I’d like to know is there’s a way to run a command when the secondary node comes online to automate this process…
try using sp_control_dbmasterkey_password on the mirror add the database and password to use.
When the principal switches to mirror it looks through the key storage to find a password to open the db key. Once open, the Service master key auto encrypts.
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.