Hello friends, on certain occasions, some clients, for whatever reason, ask us to migrate a supposedly “equivalent” brand of an engine in terms of belonging to the MySQL family or ecosystem.

In this case, we will be analyzing the migration of MariaDB to Percona Server for MySQL 8 in particular. A comment worth clarifying is that, although Percona Server for MySQL is a drop-in replacement for MySQL since it offers compatibility continuity (Percona Server for MySQL even offers certain features that the community version does not, for free!), the same does not happen with MariaDB, which from a specific version, we could say in some way, distanced itself from MySQL and Percona Server for MySQL. Much has been said about the subject, and several interesting links on the ‘net talk about it.

In this opportunity, we will focus strictly on how the migration should be done, and in particular, I will “zoom” (if you allow me the analogy) in on everything related to security.

Based on our experience, the safest way to migrate MariaDB to Percona Server for MySQL is logical. For this, we recommend using mydumper since it offers several advantages over mysqldump, such as parallelism, compression, and other features that make it really interesting.

With all this said, what would be the steps to follow at a general plan level? Basically, it would be something like:

  • Make a logical backup from MariaDB using mydymper.
  • Upload that dump to the Percona Server for MySQL using myloader.

Simple, right? No, my friend, it’s not that simple. Leaving aside certain complexities regarding the compatible data types, and the code created in the instance (Store Procedures, Functions, etc.), which we will not talk about in this blog, there is another fence that many underestimate and is essential: Security.

Why do I bother talking about this? Because in MariaDB (also in Percona Server for MySQL 8), there are ROLES and such, they may have been used. Roles are very convenient for grouping permissions and assigning them to users. That has already been discussed, and here we can see one example.

So what would the steps be like now? We would have to:

  • Make a security backup of the “source” instance (MariaDB) for this. The most practical/usual is to use pt-show-grants.
  • Once the users, roles, etc., have been created, execute the two steps mentioned above but with the caveat that ONLY the application schemas will be exported/imported AND NOT those of the internal data dictionary (such as sys, mysql, information_schema, and so on).

Alright, let’s go to the example to see if it’s as easy as it seems.

Let’s create the table and insert data into it.

Let’s start creating roles, and users, and assigning them:

We check everything:

And this is where all the magic begins.

On a third server, to avoid file transfers, etc., we execute the following commands:

a) The security stuff:

b)  The data migration stuff (clarification: in this “somewhere” there should be enough space to be able to hold the data that we want to migrate). 

And that’s it.

Now you will say, why didn’t you directly use the output of MariaDB’s pt-show-grants and perform all these series of witchcraft or cheap tricks? I’ll tell you, friend: unfortunately, the tool is not very friendly to MariaDB. Although it decently generates “something” as output, it is insufficient, and the project will undoubtedly fail.

See the output generated by pt-show-grants (I’ve filtered headers and comments, not much) for the MariaDB instance:

  • Do you see the CREATE USER command and password authentication method needed in Percona Server for MySQL 8? I don’t (hence the step1.sql).
  • Do you see any password manipulation that might work using MariaDB commands but on Percona Server for MySQL 8? I don’t think so (hence the step2.sql).
  • The only step to get the most out of the utility is in the role assignment (step3.sql).
  • Do you see the GRANTS assigned to the schemas? I don’t (that’s why the step4.sql).

This is the output of pt-show-grants for the migrated instance (Percona Server for MySQL 8):

It is what it should be.

Conclusion

Since MariaDB has gone farther away from MySQL, migrating back to the MySQL ecosystem and hence to Percona Server for MySQL is not as straightforward as it could be. Due to the same reasons, Percona Toolkit will not be able to assist in the migration task. This blog post will give you the tricks needed for a successful migration.

Of course, you always have the chance to contact us and ask for assistance with any migration.  You can also learn how Percona experts can help you migrate to Percona Server for MySQL seamlessly here.

I hope you enjoyed the blog, and see you in the next one!

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!

 

Try Percona Distribution for MySQL today!

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Karl Levik

Did you consider the special --system=users option to mariadb-dump?

From man mariadb-dump:

• users – the users, roles and their grants outputed as CREATE USER,
CREATE ROLE, GRANT, and SET DEFAULT ROLE (ALTER USER for MySQL-8.0+).