Skip to content

Instantly share code, notes, and snippets.

@tiagosampaio
Last active July 5, 2022 12:43
Show Gist options
  • Save tiagosampaio/552e5d6aecc376b84f5dad4e0893d3c0 to your computer and use it in GitHub Desktop.
Save tiagosampaio/552e5d6aecc376b84f5dad4e0893d3c0 to your computer and use it in GitHub Desktop.

Remove DEFINER clause from MySQL Dumps

sed -i 's/DEFINER=[^*]*\*/\*/g' mydump.sql

In macOS:

sed -i '' 's/DEFINER=[^*]*\*/\*/g' mydump.sql

You also export the file already without the definers:

mysqlpump -u user -p -h localhost database | sed -i 's/DEFINER=[^*]*\*/\*/g' > mydump.sql

On macOs:

mysqlpump -u user -p -h localhost database | sed -i '' 's/DEFINER=[^*]*\*/\*/g' > mydump.sql

When you're gonna backup the database you can use the option --skip-definer to create the dump already without the definers:

mysqlpump -u user --password='password' -h localhost --skip-definer database > database-no-definers.sql

More info here: https://dev.mysql.com/doc/refman/5.7/en/mysqlpump.html#option_mysqlpump_skip-definer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment