Lesson Learned #112: Exporting Azure Database for MySQL to a Blob Storage
Published Nov 17 2019 04:42 AM 3,233 Views

We received multiple questions about how to export databases of Azure Database for MySQL, PostgreSQL or MariaDB to an Azure Blob Storage. We have several ways, for example:

 

This time I would like to share with you a lesson learned about how to export a database of MySQL using the Azure File Share creating a folder where saved my exported file and making accessible from anywhere using my credentials:

 

  • Phase 1: I created a virtual machine in Azure in the same region that your Azure Database for MySQL is running on.
  • Phase 2: Depending on the size of your database, you could attach a storage or create a File Share in any storage account. In this case, I chosen to use Azure File Share.

cmdkey /add:myblobstoragename.file.core.windows.net /user:Azure\myblobstoragename /pass:AccessKey

net use Z: \\myblobstoragename.file.core.windows.net\mysqlexport /persistent:Yes

 

  • Phase 3: After installing MySQLWorkbench or MySQL Utilities I executed the following command to export the database, creating the backup file z:\bkp18112019.sql

 

    • “C:\Program Files\MySQL\MySQL Workbench 8.0 CE\mysqldump” --host mysqlservername.mysql.database.azure.com --user username@mysqlservername -p --databases databasename --column-statistics=0 --compress --verbose > c:\temp\bkp31082019.sql
    • I used –column-statistics due to my database, if you have any issue with the statistics please use this modifier.

 

 

    • "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\mysql.exe" --host newmysqlservername.mysql.database.azure.com --user username@newmysqlservername -p <z:\bkp18112019.sql

 

With this process, you will be able to export and import the database. Using Azure File Share you could connect to this service from any Windows, Linux or MacOS platform to manage the file.

 

Version history
Last update:
‎Nov 17 2019 04:43 AM
Updated by: