You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/mariadb/howto-migrate-dump-restore.md
+33-25Lines changed: 33 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,18 +6,20 @@ author: savjani
6
6
ms.author: pariks
7
7
ms.subservice: migration-guide
8
8
ms.topic: how-to
9
-
ms.date: 06/24/2022
9
+
ms.date: 04/19/2023
10
10
---
11
11
12
12
# Migrate your MariaDB database to an Azure database for MariaDB by using dump and restore
13
13
14
14
This article explains two common ways to back up and restore databases in your Azure database for MariaDB:
15
-
- Dump and restore by using a command-line tool (using mysqldump)
16
-
- Dump and restore using phpMyAdmin
15
+
16
+
- Dump and restore by using a command-line tool (using mysqldump).
17
+
- Dump and restore using phpMyAdmin.
17
18
18
19
## Prerequisites
19
20
20
21
Before you begin migrating your database, do the following:
22
+
21
23
- Create an [Azure Database for MariaDB server - Azure portal](quickstart-create-mariadb-server-database-using-azure-portal.md).
22
24
- Install the [mysqldump](https://mariadb.com/kb/en/library/mysqldump/) command-line utility.
23
25
- Download and install [MySQL Workbench](https://dev.mysql.com/downloads/workbench/) or another third-party MySQL tool for running dump and restore commands.
@@ -30,38 +32,41 @@ Use common utilities and tools such as MySQL Workbench or mysqldump to remotely
30
32
31
33
You can use MySQL utilities such as mysqldump and mysqlpump to dump and load databases into an Azure database for MariaDB server in several common scenarios.
32
34
33
-
- Use database dumps when you're migrating an entire database. This recommendation holds when you're moving a large amount of data, or when you want to minimize service interruption for live sites or applications.
34
-
-Make sure that all tables in the database use the InnoDB storage engine when you're loading data into your Azure database for MariaDB. Azure Database for MariaDB supports only the InnoDB storage engine, and no other storage engines. If your tables are configured with other storage engines, convert them into the InnoDB engine format before you migrate them to your Azure database for MariaDB.
35
+
- Use database dumps when you're migrating an entire database. This recommendation holds when you're moving a large amount of data, or when you want to minimize service interruption for live sites or applications.
36
+
- Make sure that all tables in the database use the InnoDB storage engine when you're loading data into your Azure database for MariaDB. Azure Database for MariaDB supports only the InnoDB storage engine, and no other storage engines. If your tables are configured with other storage engines, convert them into the InnoDB engine format before you migrate them to your Azure database for MariaDB.
35
37
36
38
For example, if you have a WordPress app or a web app that uses MyISAM tables, first convert those tables by migrating them into InnoDB format before you restore them to your Azure database for MariaDB. Use the clause `ENGINE=InnoDB` to set the engine to use for creating a new table, and then transfer the data into the compatible table before you restore it.
37
39
38
40
```sql
39
41
INSERT INTO innodb_table SELECT*FROM myisam_table ORDER BY primary_key_columns
40
42
```
43
+
41
44
- To avoid any compatibility issues when you're dumping databases, ensure that you're using the same version of MariaDB on the source and destination systems. For example, if your existing MariaDB server is version 10.2, you should migrate to your Azure database for MariaDB that's configured to run version 10.2. The `mysql_upgrade` command doesn't function in an Azure Database for MariaDB server, and it isn't supported. If you need to upgrade across MariaDB versions, first dump or export your earlier-version database into a later version of MariaDB in your own environment. You can then run `mysql_upgrade` before you try migrating into your Azure database for MariaDB.
42
45
43
46
## Performance considerations
44
47
45
48
To optimize performance when you're dumping large databases, keep in mind the following considerations:
46
-
- Use the `exclude-triggers` option in mysqldump. Exclude triggers from dump files to avoid having the trigger commands fire during the data restore.
47
-
- Use the `single-transaction` option to set the transaction isolation mode to REPEATABLE READ and send a START TRANSACTION SQL statement to the server before dumping data. Dumping many tables within a single transaction causes some extra storage to be consumed during the restore. The `single-transaction` option and the `lock-tables` option are mutually exclusive. This is because LOCK TABLES causes any pending transactions to be committed implicitly. To dump large tables, combine the `single-transaction` option with the `quick` option.
48
-
- Use the `extended-insert` multiple-row syntax that includes several VALUE lists. This approach results in a smaller dump file and speeds up inserts when the file is reloaded.
49
-
- Use the `order-by-primary` option in mysqldump when you're dumping databases, so that the data is scripted in primary key order.
50
-
- Use the `disable-keys` option in mysqldump when you're dumping data, to disable foreign key constraints before the load. Disabling foreign key checks helps improve performance. Enable the constraints and verify the data after the load to ensure referential integrity.
51
-
- Use partitioned tables when appropriate.
52
-
- Load data in parallel. Avoid too much parallelism, which could cause you to hit a resource limit, and monitor resources by using the metrics available in the Azure portal.
53
-
- Use the `defer-table-indexes` option in mysqlpump when you're dumping databases, so that index creation happens after table data is loaded.
49
+
50
+
- Use the `exclude-triggers` option in mysqldump. Exclude triggers from dump files to avoid having the trigger commands fire during the data restore.
51
+
- Use the `single-transaction` option to set the transaction isolation mode to REPEATABLE READ and send a START TRANSACTION SQL statement to the server before dumping data. Dumping many tables within a single transaction causes some extra storage to be consumed during the restore. The `single-transaction` option and the `lock-tables` option are mutually exclusive. This is because LOCK TABLES causes any pending transactions to be committed implicitly. To dump large tables, combine the `single-transaction` option with the `quick` option.
52
+
- Use the `extended-insert` multiple-row syntax that includes several VALUE lists. This approach results in a smaller dump file and speeds up inserts when the file is reloaded.
53
+
- Use the `order-by-primary` option in mysqldump when you're dumping databases, so that the data is scripted in primary key order.
54
+
- Use the `disable-keys` option in mysqldump when you're dumping data, to disable foreign key constraints before the load. Disabling foreign key checks helps improve performance. Enable the constraints and verify the data after the load to ensure referential integrity.
55
+
- Use partitioned tables when appropriate.
56
+
- Load data in parallel. Avoid too much parallelism, which could cause you to hit a resource limit, and monitor resources by using the metrics available in the Azure portal.
57
+
- Use the `defer-table-indexes` option in mysqlpump when you're dumping databases, so that index creation happens after table data is loaded.
54
58
- Copy the backup files to an Azure blob store and perform the restore from there. This approach should be a lot faster than performing the restore across the internet.
55
59
56
60
## Create a backup file
57
61
58
62
To back up an existing MariaDB database on the local on-premises server or in a virtual machine, run the following command by using mysqldump:
-*\<pass>*: The password for your database (note that there is no space between -p and the password)
67
72
-*\<dbname>*: The name of your database
@@ -71,18 +76,19 @@ The parameters to provide are:
71
76
For example, to back up a database named *testdb* on your MariaDB server with the user name *testuser* and with no password to a file testdb_backup.sql, use the following command. The command backs up the `testdb` database into a file called `testdb_backup.sql`, which contains all the SQL statements needed to re-create the database.
72
77
73
78
```bash
74
-
$ mysqldump -u root -p testdb > testdb_backup.sql
79
+
mysqldump -u root -p testdb > testdb_backup.sql
75
80
```
81
+
76
82
To select specific tables to back up in your database, list the table names, separated by spaces. For example, to back up only table1 and table2 tables from the *testdb*, follow this example:
In this example, you restore the data into the newly created database on the target Azure Database for MariaDB server.
109
115
110
116
```bash
111
-
$ mysql -h mydemoserver.mariadb.database.azure.com -u myadmin@mydemoserver -p testdb < testdb_backup.sql
117
+
mysql -h mydemoserver.mariadb.database.azure.com -u myadmin@mydemoserver -p testdb < testdb_backup.sql
112
118
```
113
119
114
120
## Export your MariaDB database by using phpMyAdmin
115
121
116
122
To export, you can use the common tool phpMyAdmin, which might already be installed locally in your environment. To export your MariaDB database, do the following:
123
+
117
124
1. Open phpMyAdmin.
118
125
1. On the left pane, select your database, and then select the **Export** link. A new page appears to view the dump of database.
119
-
1. In the **Export** area, select the **Select All** link to choose the tables in your database.
120
-
1. In the **SQL options** area, select the appropriate options.
126
+
1. In the **Export** area, select the **Select All** link to choose the tables in your database.
127
+
1. In the **SQL options** area, select the appropriate options.
121
128
1. Select the **Save as file** option and the corresponding compression option, and then select **Go**. At the prompt, save the file locally.
122
129
123
130
## Import your database by using phpMyAdmin
124
131
125
132
The importing process is similar to the exporting process. Do the following:
126
-
1. Open phpMyAdmin.
127
-
1. On the phpMyAdmin setup page, select **Add** to add your Azure Database for MariaDB server.
133
+
134
+
1. Open phpMyAdmin.
135
+
1. On the phpMyAdmin setup page, select **Add** to add your Azure Database for MariaDB server.
128
136
1. Enter the connection details and login information.
129
-
1. Create an appropriately named database, and then select it on the left pane. To rewrite the existing database, select the database name, select all the check boxes beside the table names, and select **Drop** to delete the existing tables.
130
-
1. Select the **SQL** link to show the page where you can enter SQL commands or upload your SQL file.
131
-
1. Select the **browse** button to find the database file.
137
+
1. Create an appropriately named database, and then select it on the left pane. To rewrite the existing database, select the database name, select all the check boxes beside the table names, and select **Drop** to delete the existing tables.
138
+
1. Select the **SQL** link to show the page where you can enter SQL commands or upload your SQL file.
139
+
1. Select the **browse** button to find the database file.
132
140
1. Select the **Go** button to export the backup, execute the SQL commands, and re-create your database.
0 commit comments