Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude DEFINER on Database Export #179

Open
planetahuevo opened this issue Oct 8, 2020 · 4 comments
Open

Exclude DEFINER on Database Export #179

planetahuevo opened this issue Oct 8, 2020 · 4 comments

Comments

@planetahuevo
Copy link

Feature Request

Describe your use case and the problem you are facing

When exporting databases, it is a common issue that sometimes the restoration cannot be completed due to this line (or similar:

/*!50013 DEFINER=user@% SQL SECURITY DEFINER */

When this happens, the import normally fails with error when trying to import it.
Some links with the issue (from 2010 one of them):
https://dbperf.wordpress.com/2010/04/12/removing-definer-from-mysql-dump/
https://stackoverflow.com/questions/9446783/remove-definer-clause-from-mysql-dumps

Describe the solution you'd like

I think that adding an option to exclude the DEFINER from the export or to remove it after the export automatically will improve the reliability of the export data.

Alternatively could be that the IMPORT ignore that line, but I think this is more an export issue than a import one.
Thanks!

@schlessera schlessera transferred this issue from wp-cli/wp-cli Oct 15, 2020
@schlessera
Copy link
Member

The WordPress schema is very primitive, it doesn't contain any stored procedures or similar.

Therefore I think we should be safe by either stripping the DEFINER and falling back to the defaults, or setting the DEFINER to CURRENT_USER(), which should be the same as the defaults. This could indeed be done via an export switch like --skip-definer or --adapt-definer.

I'd love for more feedback on this by database experts, though, as this can potentially be a risky proposition...

@planetahuevo
Copy link
Author

I agree. I am not a db expert either so it would be great to have some other input on this. :)
We can wait. It is not a critical thing to have at all.

@planetahuevo
Copy link
Author

planetahuevo commented Nov 8, 2021

Hi,
One year since this one I have another issue again with this.
It is clearly not a big deal with most websites, but when it fails, it fails completely.
It would be great to have this option or any alternative.

https://aws.amazon.com/premiumsupport/knowledge-center/definer-error-mysqldump/

@schlessera
Copy link
Member

For now, you should be able to use a work-around by stripping the offending line with sed:

wp @production db export - | sed 's#/\*[^/]*DEFINER[^/]*\*/##' | wp @staging db import -

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

No branches or pull requests

2 participants