I have a bash script that imports wordpress dbs for me pretty reliably, but one of my sites came from a former wordpress multisite, therefore the database includes DEFINERS within the database that prevents the following code from executing correctly
gunzip -c $destination_path_to_wordpress/folder/db-export.sql.gz | mysql -u $destination_db_user -p$destination_db_pass $destination_db_name
The above results in ERROR 1227 (42000) at line 3224: Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation
If I manually export the db then run sed 's/\sDEFINER=`[^`]*`@`[^`]*`//g' -i db-export.sql and then attempt to import the db then I can successfully import the db, search-replace the user name, and site it live.
Question:
What is the correct syntax to to combine my current db import command and the sed command that gets rid of the definer problem? something like the following is what I would like to achieve:
clearly incorrect, but you get the gist...
gunzip -c $destination_path_to_wordpress/folder/db-export.sql.gz | `sed 's/\sDEFINER=`[^`]*`@`[^`]*`//g' -i db-export.sql | mysql -u $destination_db_user -p$destination_db_pass $destination_db_name
any tips?
thanks