0

I am writing a bash script to export a few tables from the MySQL DB and import in the backup DB. I will repeat this process on an hourly basis and will keep all the tables by changing the table name.

The issue I am facing is in creating the tables as few tables have CONSTRAINT like the foreign key and unique. Since I am exporting and importing multiple times the key names are the same and the bash script exists with the error Can't create table (error:121).

I searched and got that this is due to CONSTRAINT.

Is there a way to export or import ignoring the CONSTRAINT.

The Mysql engine is Innodb and commands are as follows -

mysqldump --disable-keys --skip-triggers --single-transaction --lock-tables=false  --user=$USER --password=$PASS --host=$HOST $element $item >> $backup_path/$tableName1.sql

mysql --user=$USER --password=$PASS --host=$HOST $DB  < $backup_path/$table.sql

Thanks in advance

  • 1
    <snide-remark>Sometimes FKs are more trouble than they are worth.</snide-remark> – Rick James Jan 4 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.