MySQL to MySQL Migration Guide 1746623694
MySQL to MySQL Migration Guide 1746623694
moving login
moving login
The steps involve installing Percona Toolkit to be able to use the Percona tool pt-show-grant . The
tool will print out the users with their privileges and encrypted passwords. The following are the steps
needed to successfully migrate a MySQL database and users to another MySQL server:
select the version and the correct OS version , then copy link from download button , we will use it along
side wget
wget https://downloads.percona.com/downloads/percona-
toolkit/3.5.7/binary/redhat/8/x86_64/percona-toolkit-3.5.7-1.el8.x86_64.rpm?
_gl=1*2fna65*_gcl_au*MTA0Mzk1MDYyOS4xNzE1NjkwMzk5
use yum localinstall to install percona toolkit
When using pt-show-grant , MySQL will print the password in a format that cannot be executed on the
other side. To resolve this, you need to set the global variable
PERSIST.print_identified_with_as_hex to 1 . First, log in to MySQL and then execute the
following command:
SET @@PERSIST.print_identified_with_as_hex = 1;
note : make sure to apply the user logins after migrating the databases, since some logins may have
permissions on specific databases or tables.
Since we have moved the login file to the destination MySQL server, we will start applying the logins. It
is best practice to apply the logins manually to avoid overriding system users and the root user on the
destination MySQL server.
the file separate each user with the sentence -- Grants for
we should avoid system user and root user
we will start with the below normal user and apply them
The syntax for users will contain CREATE USER , followed by ALTER USER on the next line to define the
password. We should reconstruct the query to include CREATE USER along with the password definition.
below example
**orginial query **
**query after **
we simple taking merged the create user and alter user to gather to constructed single query
now we will execute the query MySQL
GRANT
APPLICATION_PASSWORD_ADMIN,AUDIT_ABORT_EXEMPT,AUDIT_ADMIN,AUTHENTICATION_POL
ICY_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONN
ECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FIREWALL_EXEMPT,FLUSH_OPTIMIZER_COSTS,FLUS
H_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,GROUP_REP
LICATION_STREAM,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PASSWORDLESS_
USER_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_
ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SENSITIVE_VARIABLE
S_OBSERVER,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW
_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,TELEMETRY
_LOG_ADMIN,XA_RECOVER_ADMIN ON *.* TO `user_3a4b5c6d`@`localhost`;
now you can continue doing the same to other account
For this step, we will take a database dump using the mysqldump tool. While it is possible to take a
dump of the entire MySQL server, restoring it on the destination server will override users and other
system databases. The best practice is to back up only the user database.
First, list the databases and determine the databases we would like to migrate.
for this purpose we will be migrating sakila database
we can mention multiple database but for our purpose we only have one database