Mysqldump without triggers

22.1k Views Asked by At

I'm using mysqldump to share databases dumps, but I'm having an issue with triggers. The command does not add "drop" or "replace" lines with the triggers, making people who already added a previous dump with same triggers names having an error :

ERROR 1359 (HY000) at line 1420: Trigger already exists

I've read on forums people saying it's a missing feature for MySQL, but all posts are old and I'm wondering if there could be a way to do it now.

I know there is a way to dump schema and data separately, but i'd like to keep a single dump to share.

3

There are 3 best solutions below

0
On BEST ANSWER

There's a mysqldump option --skip-triggers you should use that to skip triggers.

2
On

You don't specify version. mysqldump 5.6 and above has --add-drop-trigger option.

0
On

For example, using --skip-triggers, you can export the schema and data of the tables of apple database without its triggers to backup.sql as shown below. *By default, trigers are exported by implicit --triggers and my answer explains how to perfectly export databases:

mysqldump -u john -p --skip-triggers apple > backup.sql