Restart Azure Database for MySQL server using PowerShell
APPLIES TO: Azure Database for MySQL - Single Server
Important
Azure Database for MySQL single server is on the retirement path. We strongly recommend that you upgrade to Azure Database for MySQL flexible server. For more information about migrating to Azure Database for MySQL flexible server, see What's happening to Azure Database for MySQL Single Server?
This topic describes how you can restart an Azure Database for MySQL server. You may need to restart your server for maintenance reasons, which causes a short outage during the operation.
The server restart is blocked if the service is busy. For example, the service may be processing a previously requested operation such as scaling vCores.
The amount of time required to complete a restart depends on the MySQL recovery process. To reduce the restart time, we recommend you minimize the amount of activity occurring on the server before the restart.
Prerequisites
To complete this how-to guide, you need:
- The Az PowerShell module installed locally or Azure Cloud Shell in the browser
- An Azure Database for MySQL server
Important
While the Az.MySql PowerShell module is in preview, you must install it separately from the Az
PowerShell module using the following command: Install-Module -Name Az.MySql -AllowPrerelease
.
Once the Az.MySql PowerShell module is generally available, it becomes part of future Az
PowerShell module releases and available natively from within Azure Cloud Shell.
Note
If the user restarting the server is part of custom role the user should have write privilege on the server.
If you choose to use PowerShell locally, connect to your Azure account using the Connect-AzAccount cmdlet.
Azure Cloud Shell
Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. You can use either Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell preinstalled commands to run the code in this article, without having to install anything on your local environment.
To start Azure Cloud Shell:
Option | Example/Link |
---|---|
Select Try It in the upper-right corner of a code or command block. Selecting Try It doesn't automatically copy the code or command to Cloud Shell. | |
Go to https://shell.azure.com, or select the Launch Cloud Shell button to open Cloud Shell in your browser. | |
Select the Cloud Shell button on the menu bar at the upper right in the Azure portal. |
To use Azure Cloud Shell:
Start Cloud Shell.
Select the Copy button on a code block (or command block) to copy the code or command.
Paste the code or command into the Cloud Shell session by selecting Ctrl+Shift+V on Windows and Linux, or by selecting Cmd+Shift+V on macOS.
Select Enter to run the code or command.
Restart the server
Restart the server with the following command:
Restart-AzMySqlServer -Name mydemoserver -ResourceGroupName myresourcegroup