Mysqldump Fully Qualifies Triggers with Database Name

I am trying to use mysqldump to export a database that must be imported using a different database name. Looking at the SQL generated by mysqldump, it seems that triggers are the only object names that fully match the source database name, which deprives my needs. Is there anyway to direct mysqldump not to fully-qualify any object names, including triggers?

+5
source share
3 answers

I had the same problem and found a solution. I used the MySQL Workbench to develop my database, and I created triggers there. They all used the syntax CREATE TRIGGER trigger_nameexcept for one: CREATE TRIGGER dbname.trigger_name(it was my mistake). Mysqldump output included all triggers the same way: only one had a database name.

Mysqldump uses your original instructions CREATE TRIGGER, which you can see through SHOW CREATE TRIGGER. If you have a trigger defined with the database name, just replace it (drop and create) with one without dbname.

+2
source

Most likely, you add the database name when creating the trigger. Try updating the trigger without the database name in it.

+1
source

, .

mysqldump ... opts ... | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' 
0

All Articles