Migration of MySQL databases to cloud databases
Migration of MySQL databases to cloud databases
You can migrate data from your MySQL database to cloud databases:
- Create SQL dump.
- Restore the database from the SQL dump.
Only InnoDB is supported.
For your information
Before migrating, make sure that MySQL DBMS versions match. We do not guarantee migration between different versions. Read more in official documentation.
Create SQL dump
Create a SQL dump of the database 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>
— the name of the database user in the source;<password>
— database user password;<host>
— DNS or IP address of the node;<port>
— port to connect to the database;--set-gtid-purged=off
— key indicates that replication based on global GTIDs is not used;--no-tablespaces
— cancel the addition of service information to the dump that requires additional permissions to access. This information does not affect user data and can be excluded from the dump;--single-transaction
— creating a SQL dump as a single transaction;<database_name>
— database name.
Restore database from SQL dump
Restore the database from SQL dump using the mysql utility:
mysql --user=<user_name> \
--password=<password> \
--host=<host> \
--port=3306 <database_name> < dump.sql
Specify:
<user_name>
— the user name of the cloud 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, set additional parameters --ssl-ca
и --ssl-mode
:
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>
— the user name of the cloud database;<password>
— database user password;<host>
— DNS or IP address of the node;<database_name>
— database name.