9

I was wondering if I can prevent mysqldump inserting this commands

/*!50017 DEFINER=`root`@`localhost`*/

Or if I have to do it afterwards with sed, for example

Thanks!

Emilio Nicolás
  • 2,554
  • 5
  • 22
  • 29
  • http://stackoverflow.com/a/1917437/477878 – Joachim Isaksson Aug 10 '12 at 12:10
  • possible duplicate of [How can I get rid of these comments in a MySQL dump?](http://stackoverflow.com/questions/1916392/how-can-i-get-rid-of-these-comments-in-a-mysql-dump) – Joachim Isaksson Aug 10 '12 at 12:11
  • I don't think this is a duplicate of that question, because it is specifically about DEFINER, which can cause difficulties when importing a dump on a different machine. It is basically a duplicate of http://stackoverflow.com/questions/9446783/remove-definer-clause-from-mysql-dumps – seanf Jan 25 '13 at 03:57
  • Possible duplicate of [Remove DEFINER clause from MySQL Dumps](http://stackoverflow.com/questions/9446783/remove-definer-clause-from-mysql-dumps) – Matteo Tassinari Apr 07 '17 at 08:49

1 Answers1

12

This issue has been around since 2006 with no sign of ever being fixed.

I have, however, piped it through grep (linux only) to trim out the definer lines before writing the dump file:

mysqldump -u dbuser -p dbname | grep -v 'SQL SECURITY DEFINER' > dump.sql

A bit of a mouthful (or keyboardful?) but I think it's the only way.

NickJ
  • 9,380
  • 9
  • 51
  • 74