Skip to main content

Migration of MySQL databases to MySQL semi-sync Managed Databases

You can migrate data from your MySQL database to Managed Databases:

  1. Create an SQL dump.
  2. Restore the database from the SQL dump.

Only InnoDB is supported.

For your information

Before migration, ensure that the MySQL DBMS versions match. We do not guarantee successful migration between different versions. For more details, see the official documentation.

Create an SQL dump

Create an SQL database dump using the mysqldump utility:

mysqldump --user=<user_name> \
--password=<password> \
--host=<host> \
--port=<port> \
--set-gtid-purged=off \
--no-tablespaces \
--single-transaction <database_name> > dump.sql

Specify:

  • <user_name> — database user name in the source;
  • <password> — database user password;
  • <host> — DNS or IP address of the node;
  • <port> — port for connecting to the database;
  • --set-gtid-purged=off — this flag indicates that replication based on global transaction identifiers (GTID) is not used;
  • --no-tablespaces — disables the addition of service information to the dump, which requires additional permissions to access. This information does not affect user data and can be excluded from the dump;
  • --single-transaction — creates an SQL dump within a single transaction;
  • <database_name> — database name.

Restore the database from an SQL dump

Restore the database from an SQL dump using the mysql utility:

mysql --user=<user_name> \
--password=<password> \
--host=<host> \
--port=3306 <database_name> < dump.sql

Specify:

  • <user_name> — username of the Managed Database;
  • <password> — database user password;
  • <host> — DNS or IP address of the node;
  • <database_name> — database name.

If you are connecting with an SSL certificate, specify the additional --ssl-ca and --ssl-mode: parameters:

mysql --user=<user_name> \
--password=<password> \
--host=<host> \
--port=3306 \
--ssl-ca=~/.mysql/root.crt \
--ssl-mode=required <database_name> < dump.sql

Specify:

  • <user_name> — username of the Managed Database;
  • <password> — database user password;
  • <host> — DNS or IP address of the node;
  • <database_name> — database name.