Removing Definer line from mysqldump

I’ve had issues from time to time where a sql file won’t import because if has a definer in it that doesn’t match the server I’m trying to import the file to.

A simple linux command can replace the definer in these dump files to be the current user allowing everything to work as intended.

 

 

sed -E 's/DEFINER=`[^`]+`@`[^`]+`/DEFINER=CURRENT_USER/g' mydatabase.sql > mycleandatabase.sql

This works for Debian based Linux systems, which is what I work on.

Leave a Reply

Your email address will not be published. Required fields are marked *