|
| 1 | +--- |
| 2 | +title: Azure Database for MySQL - flexible server - major version upgrade |
| 3 | +description: Learn how to upgrade major version for an Azure Database for MySQL - Flexible server. |
| 4 | +ms.service: mysql |
| 5 | +ms.subservice: flexible-server |
| 6 | +ms.topic: how-to |
| 7 | +author: code-sidd |
| 8 | +ms.author: sisawant |
| 9 | +ms.date: 9/26/2022 |
| 10 | +--- |
| 11 | + |
| 12 | +# Major version upgrade in Azure Database for MySQL flexible server preview |
| 13 | + |
| 14 | +[!INCLUDE[applies-to-mysql-flexible-server](../includes/applies-to-mysql-flexible-server.md)] |
| 15 | + |
| 16 | +>[!Note] |
| 17 | +> This article contains references to the term slave, a term that Microsoft no longer uses. When the term is removed from the software, we will remove it from this article. |
| 18 | +
|
| 19 | +This article describes how you can upgrade your MySQL major version in-place in Azure Database for MySQL Flexible server. |
| 20 | +This feature will enable customers to perform in-place upgrades of their MySQL 5.7 servers to MySQL 8.0 with a click of button without any data movement or the need of any application connection string changes. |
| 21 | + |
| 22 | +>[!Important] |
| 23 | +> - Major version upgrade for Azure database for MySQL Flexible Server is available in public preview. |
| 24 | +> - Major version upgrade is currently not available for Burstable SKU 5.7 servers. |
| 25 | +> - Duration of downtime will vary based on the size of your database instance and the number of tables on the database. |
| 26 | +> - Upgrading major MySQL version is irreversible. Your deployment might fail if validation identifies the server is configured with any features that are [removed](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals) or [deprecated](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-deprecations). You can make necessary configuration changes on the server and try upgrade again |
| 27 | +
|
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +- Read Replicas with MySQL version 5.7 should be upgraded before Primary Server for replication to be compatible between different MySQL versions, read more on [Replication Compatibility between MySQL versions](https://dev.mysql.com/doc/mysql-replication-excerpt/8.0/en/replication-compatibility.html). |
| 31 | +- Before you upgrade your production servers, we strongly recommend you to test your application compatibility and verify your database compatibility with features [removed](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals)/[deprecated](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-deprecations) in the new MySQL version. |
| 32 | +- Trigger [on-demand backup](./how-to-trigger-on-demand-backup.md) before you perform major version upgrade on your production server, which can be used to [rollback to version 5.7](./how-to-restore-server-portal.md) from the full on-demand backup taken. |
| 33 | + |
| 34 | + |
| 35 | +## Perform Planned Major version upgrade from MySQL 5.7 to MySQL 8.0 using Azure portal |
| 36 | + |
| 37 | +1. In the [Azure portal](https://portal.azure.com/), select your existing Azure Database for MySQL 5.7 server. |
| 38 | + >[!Important] |
| 39 | + > We recommend performing upgrade first on restored copy of the server rather than upgrading production directly. See [how to perform point-in-time restore](./how-to-restore-server-portal.md). |
| 40 | +
|
| 41 | +2. From the overview page, click the Upgrade button in the toolbar |
| 42 | + |
| 43 | + >[!Important] |
| 44 | + > Before upgrading visit link for list of [features removed](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals) in MySQL 8.0. |
| 45 | + > Verify deprecated [sql_mode](/https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_mode) values and remove/deselect them from your current Flexible Server 5.7 using Server Parameters Blade on your Azure Portal to avoid deployment failure. |
| 46 | + > [sql_mode](/https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_mode) with values NO_AUTO_CREATE_USER, NO_FIELD_OPTIONS, NO_KEY_OPTIONS and NO_TABLE_OPTIONS are no longer supported in MySQL 8.0. |
| 47 | + |
| 48 | + :::image type="content" source="./media/how-to-upgrade/1-how-to-upgrade.png" alt-text="Screenshot showing Azure Database for MySQL Upgrade."::: |
| 49 | + |
| 50 | +3. In the Upgrade sidebar, verify Major Upgrade version to upgrade i.e 8.0. |
| 51 | + |
| 52 | + :::image type="content" source="./media/how-to-upgrade/2-how-to-upgrade.png" alt-text="Screenshot showing Upgrade."::: |
| 53 | + |
| 54 | +4. For Primary Server, click on confirmation checkbox, to confirm that all your replica servers are upgraded before primary server. Once confirmed that all your replicas are upgraded, Upgrade button will be enabled. For your read-replicas and standalone servers, Upgrade button will be enabled by default. |
| 55 | + |
| 56 | + :::image type="content" source="./media/how-to-upgrade/3-how-to-upgrade.png" alt-text="Screenshot showing confirmation."::: |
| 57 | + |
| 58 | +5. Once Upgrade button is enabled, you can click on Upgrade button to proceed with deployment. |
| 59 | + |
| 60 | + :::image type="content" source="./media/how-to-upgrade/4-how-to-upgrade.png" alt-text="Screenshot showing upgrade."::: |
| 61 | + |
| 62 | + |
| 63 | +## Perform Planned Major version upgrade from MySQL 5.7 to MySQL 8.0 using Azure CLI |
| 64 | + |
| 65 | +Follow these steps to perform major version upgrade for your Azure Database of MySQL 5.7 server using Azure CLI. |
| 66 | + |
| 67 | +1. Install [Azure CLI](/cli/azure/install-azure-cli) for Windows or use [Azure CLI](../../cloud-shell/overview.md) in Azure Cloud Shell to run the upgrade commands. |
| 68 | + |
| 69 | + This upgrade requires version 2.40.0 or later of the Azure CLI. If you are using Azure Cloud Shell, the latest version is already installed. Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade. |
| 70 | + |
| 71 | + |
| 72 | +2. After you sign in, run the [az mysql server upgrade](/cli/azure/mysql/server#az-mysql-server-upgrade) command. |
| 73 | + |
| 74 | + ```azurecli |
| 75 | + az mysql server upgrade --name testsvr --resource-group testgroup --subscription MySubscription --version 8.0 |
| 76 | + ``` |
| 77 | +
|
| 78 | +3. Under confirmation prompt, type “y” for confirming or “n” to stop the upgrade process and enter. |
| 79 | +
|
| 80 | +
|
| 81 | +## Perform major version upgrade from MySQL 5.7 to MySQL 8.0 on read replica using Azure portal |
| 82 | +
|
| 83 | +1. In the Azure portal, select your existing Azure Database for MySQL 5.7 read replica server. |
| 84 | +
|
| 85 | +2. From the Overview page, click the Upgrade button in the toolbar. |
| 86 | +>[!Important] |
| 87 | +> Before upgrading visit link for list of [features removed](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals) in MySQL 8.0. |
| 88 | +>Verify deprecated [sql_mode](/https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_mode) values and remove/deselect them from your current Flexible Server 5.7 using Server Parameters Blade on your Azure Portal to avoid deployment failure. |
| 89 | +
|
| 90 | +3. In the Upgrade section, select Upgrade button to upgrade Azure database for MySQL 5.7 read replica server to 8.0 server. |
| 91 | +
|
| 92 | +4. A notification will confirm that upgrade is successful. |
| 93 | +
|
| 94 | +5. From the Overview page, confirm that your Azure database for MySQL read replica server version is 8.0. |
| 95 | +
|
| 96 | +6. Now go to your primary server and perform major version upgrade on it. |
| 97 | +
|
| 98 | +
|
| 99 | +## Perform minimal downtime major version upgrade from MySQL 5.7 to MySQL 8.0 using read replicas |
| 100 | +
|
| 101 | +1. In the Azure portal, select your existing Azure Database for MySQL 5.7. |
| 102 | +2. Create a [read replica](./how-to-read-replicas-portal.md) from your primary server. |
| 103 | +3. Upgrade your [read replica to version](#perform-planned-major-version-upgrade-from-mysql-57-to-mysql-80-using-azure-cli) 8.0. |
| 104 | +4. Once you confirm that the replica server is running on version 8.0, stop your application from connecting to your primary server. |
| 105 | +5. Check replication status, and make sure replica is all caught up with primary, so all the data is in sync and ensure there are no new operations performed in primary. |
| 106 | +Confirm with the show slave status command on the replica server to view the replication status. |
| 107 | + ```azurecli |
| 108 | + SHOW SLAVE STATUS\G |
| 109 | + ``` |
| 110 | + If the state of Slave_IO_Running and Slave_SQL_Running are "yes" and the value of Seconds_Behind_Master is "0", replication is working well. Seconds_Behind_Master indicates how late the replica is. If the value isn't "0", it means that the replica is processing updates. Once you confirm Seconds_Behind_Master is "0" it's safe to stop replication. |
| 111 | +
|
| 112 | +6. Promote your read replica to primary by stopping replication. |
| 113 | +7. Set Server Parameter read_only to 0 i.e., OFF to start writing on promoted primary. |
| 114 | +
|
| 115 | + Point your application to the new primary (former replica) which is running server 8.0. Each server has a unique connection string. Update your application to point to the (former) replica instead of the source. |
| 116 | +
|
| 117 | +>[!Note] |
| 118 | +> This scenario will have downtime during steps 4, 5 and 6 only. |
| 119 | +
|
| 120 | +
|
| 121 | +## Frequently asked questions |
| 122 | +- Will this cause downtime of the server and if so, how long? |
| 123 | +
|
| 124 | + To have minimal downtime during upgrades, follow the steps mentioned under - [Perform minimal downtime major version upgrade from MySQL 5.7 to MySQL 8.0 using read replicas](#perform-minimal-downtime-major-version-upgrade-from-mysql-57-to-mysql-80-using-read-replicas). |
| 125 | + The server will be unavailable during the upgrade process, so we recommend you perform this operation during your planned maintenance window. The estimated downtime depends on the database size, storage size provisioned (IOPs provisioned), and the number of tables on the database. The upgrade time is directly proportional to the number of tables on the server. To estimate the downtime for your server environment, we recommend to first perform upgrade on restored copy of the server. |
| 126 | +
|
| 127 | +
|
| 128 | +- When will this upgrade feature be GA? |
| 129 | + |
| 130 | + The GA of this feature will be planned by December 2022. However, the feature is production ready and fully supported by Azure so you should run it with confidence in your environment. As a recommended best practice, we strongly suggest you run and test it first on a restored copy of the server so you can estimate the downtime during upgrade and perform application compatibility test before you run it on production. |
| 131 | + |
| 132 | +- What happens to my backups after upgrade? |
| 133 | + |
| 134 | + All backups (automated/on-demand) taken before major version upgrade, when used for restoration will always restore to a server with older version (5.7). |
| 135 | + All the backups (automated/on-demand) taken after major version upgrade will restore to server with upgraded version (8.0). It's highly recommended to take on-demand backup before you perform the major version upgrade for an easy rollback. |
| 136 | +
|
| 137 | +
|
| 138 | + ## Next steps |
| 139 | + - Learn more on [how to configure scheduled maintenance](./how-to-maintenance-portal.md) for your Azure Database for MySQL flexible server. |
| 140 | + - Learn about what's new in [MySQL version 8.0](https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html). |
0 commit comments