Migrating Ownership of Your Stored Routines, Views, and Triggers in MySQL

July 7, 2021
Author
Sveta Smirnova
Share this Post:

Migrating Ownership MySQL“It would be nice to have an option, that would allow to suppress the DEFINER statement in the CREATE VIEW statements generated by mysqldump. This would help when transferring data structures between databases with different security models.”

TLDR;

Use mysqlpump with option --skip-definer instead of mysqldump.

The Story

This was requested as MySQL Bug #24680 on Nov 29, 2006. This feature request got large Community support. Even if we cannot see the number of people who voted for this request, the number of comments is impressive.

The request is very reasonable: mysqldump is widely used during application development and it is a very common practice to migrate database structure between developers’ machines and to the production servers.

Imagine a situation where developer Sveta creates a database and adds few objects with DEFINER clauses there. We will use only one for this post but in reality, she can have dozens.

Once you create a view default DEFINER is the user who created this view:

And this causes issues when another user tries to import such a view into a different server:

Here is the content of line 61:

So this is a CREATE VIEW operation that failed during import.

Unfortunately, mysqldump still does not have an option that allows migrating definers.

But since August 2015 and MySQL 5.7.8 we have a solution that, unfortunately, was overlooked in favor of the famous tool mysqldump.

Version 5.7.8 and all which created after it, come with a new dump tool: mysqlpump that has the option --skip-definer and allows to migrate database objects without any issue:

Note that mysqlpumpautomatically adds CREATE DATABASE into the dump and full path to the database objects. E.g. CREATE ALGORITHM=UNDEFINED VIEW `definers`.`large_tables` AS select Therefore this method cannot be used to migrate view, routine, or trigger definitions between different databases on the same server.

For more information about mysqlpump and why you should switch to this tool from mysqldump read this blog post, The mysqlpump Utility.

Percona Distribution for MySQL is the most complete, stable, scalable, and secure, open-source MySQL solution available, delivering enterprise-grade database environments for your most critical business applications… and it’s free to use!

Download Percona Distribution for MySQL Today

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved