Skip to content

Commit dcfa31f

Browse files
[Doc-a-thon] Updating howto-migrate-dump-restore.md
Removing $ sign from bash block codes
1 parent 2b4e1b6 commit dcfa31f

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

articles/mariadb/howto-migrate-dump-restore.md

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ author: savjani
66
ms.author: pariks
77
ms.subservice: migration-guide
88
ms.topic: how-to
9-
ms.date: 06/24/2022
9+
ms.date: 04/19/2023
1010
---
1111

1212
# Migrate your MariaDB database to an Azure database for MariaDB by using dump and restore
1313

1414
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.
1718

1819
## Prerequisites
1920

2021
Before you begin migrating your database, do the following:
22+
2123
- Create an [Azure Database for MariaDB server - Azure portal](quickstart-create-mariadb-server-database-using-azure-portal.md).
2224
- Install the [mysqldump](https://mariadb.com/kb/en/library/mysqldump/) command-line utility.
2325
- 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
3032

3133
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.
3234

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.
3537

3638
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.
3739

3840
```sql
3941
INSERT INTO innodb_table SELECT * FROM myisam_table ORDER BY primary_key_columns
4042
```
43+
4144
- 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.
4245

4346
## Performance considerations
4447

4548
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.
5458
- 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.
5559

5660
## Create a backup file
5761

5862
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:
5963

6064
```bash
61-
$ mysqldump --opt -u <uname> -p<pass> <dbname> > <backupfile.sql>
65+
mysqldump --opt -u <uname> -p<pass> <dbname> > <backupfile.sql>
6266
```
6367

6468
The parameters to provide are:
69+
6570
- *\<uname>*: Your database user name
6671
- *\<pass>*: The password for your database (note that there is no space between -p and the password)
6772
- *\<dbname>*: The name of your database
@@ -71,18 +76,19 @@ The parameters to provide are:
7176
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.
7277

7378
```bash
74-
$ mysqldump -u root -p testdb > testdb_backup.sql
79+
mysqldump -u root -p testdb > testdb_backup.sql
7580
```
81+
7682
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:
7783

7884
```bash
79-
$ mysqldump -u root -p testdb table1 table2 > testdb_tables_backup.sql
85+
mysqldump -u root -p testdb table1 table2 > testdb_tables_backup.sql
8086
```
8187

8288
To back up more than one database at once, use the --database switch and list the database names, separated by spaces.
8389

8490
```bash
85-
$ mysqldump -u root -p --databases testdb1 testdb3 testdb5 > testdb135_backup.sql
91+
mysqldump -u root -p --databases testdb1 testdb3 testdb5 > testdb135_backup.sql
8692
```
8793

8894
## Create a database on the target server
@@ -108,27 +114,29 @@ mysql -h <hostname> -u <uname> -p<pass> <db_to_restore> < <backupfile.sql>
108114
In this example, you restore the data into the newly created database on the target Azure Database for MariaDB server.
109115

110116
```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
112118
```
113119

114120
## Export your MariaDB database by using phpMyAdmin
115121

116122
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+
117124
1. Open phpMyAdmin.
118125
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.
121128
1. Select the **Save as file** option and the corresponding compression option, and then select **Go**. At the prompt, save the file locally.
122129

123130
## Import your database by using phpMyAdmin
124131

125132
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.
128136
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.
132140
1. Select the **Go** button to export the backup, execute the SQL commands, and re-create your database.
133141

134142
## Next steps

0 commit comments

Comments
 (0)