Azure Database for MySQL PowerShell Cmdlets
This section provides reference documentation for the Azure PowerShell cmdlets used to manage Azure Database for MySQL.
Cmdlet Categories
The following cmdlets are available for managing Azure Database for MySQL. Click on a cmdlet name to see its detailed syntax, parameters, and examples.
Creates a new Azure Database for MySQL flexible server.
Gets information about an Azure Database for MySQL flexible server.
Updates an existing Azure Database for MySQL flexible server.
Deletes an Azure Database for MySQL flexible server.
Creates a network rule for an Azure Database for MySQL flexible server.
Gets network rules for an Azure Database for MySQL flexible server.
Removes a network rule for an Azure Database for MySQL flexible server.
Gets the configuration of an Azure Database for MySQL flexible server.
Updates the configuration of an Azure Database for MySQL flexible server.
Restarts an Azure Database for MySQL flexible server.
Cmdlet Details
New-AzMySqlFlexibleServer
Syntax
New-AzMySqlFlexibleServer -ResourceGroupName <String> -Name <String> -Location <Location> -SkuName <String> -StorageSizeGB <Int32> -AdministratorLogin <String> -AdministratorLoginPassword <SecureString> [-Version <MySqlVersion>] [-Zone <Int32>] [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
Description
Creates a new Azure Database for MySQL flexible server. You must specify the resource group, server name, location, SKU, storage size, administrator login, and password.
Parameters
-ResourceGroupName
: The name of the resource group.-Name
: The name of the MySQL server.-Location
: The location where the server will be created.-SkuName
: The SKU name for the server (e.g., Standard_D2s_v3, Basic_B1ms).-StorageSizeGB
: The storage size in GB.-AdministratorLogin
: The administrator login name for the server.-AdministratorLoginPassword
: The administrator login password.-Version
: The MySQL server version (e.g., '5.7', '8.0').-Zone
: The availability zone for the server.
Example
$password = ConvertTo-SecureString "MyComplexPassword123!" -AsPlainText -Force
New-AzMySqlFlexibleServer -ResourceGroupName "myResourceGroup" -Name "myMySQLServer" -Location "East US" -SkuName "Standard_D2s_v3" -StorageSizeGB 100 -AdministratorLogin "sqladmin" -AdministratorLoginPassword $password -Version "8.0" -Zone 2
Get-AzMySqlFlexibleServer
Syntax
Get-AzMySqlFlexibleServer [-ResourceGroupName <String>] [-Name <String>] [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>]
Description
Retrieves information about one or more Azure Database for MySQL flexible servers.
Parameters
-ResourceGroupName
: The name of the resource group.-Name
: The name of the MySQL server.
Example
# Get all servers in a resource group
Get-AzMySqlFlexibleServer -ResourceGroupName "myResourceGroup"
# Get a specific server
Get-AzMySqlFlexibleServer -ResourceGroupName "myResourceGroup" -Name "myMySQLServer"
Update-AzMySqlFlexibleServer
Syntax
Update-AzMySqlFlexibleServer -Name <String> -ResourceGroupName <String> [-SkuName <String>] [-StorageSizeGB <Int32>] [-AdministratorLoginPassword <SecureString>] [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
Description
Updates an existing Azure Database for MySQL flexible server.
Parameters
-Name
: The name of the MySQL server.-ResourceGroupName
: The name of the resource group.-SkuName
: The SKU name for the server.-StorageSizeGB
: The storage size in GB.-AdministratorLoginPassword
: The new administrator login password.
Example
$password = ConvertTo-SecureString "NewComplexPassword456!" -AsPlainText -Force
Update-AzMySqlFlexibleServer -Name "myMySQLServer" -ResourceGroupName "myResourceGroup" -StorageSizeGB 200 -AdministratorLoginPassword $password
Remove-AzMySqlFlexibleServer
Syntax
Remove-AzMySqlFlexibleServer -Name <String> -ResourceGroupName <String> [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
Description
Deletes an Azure Database for MySQL flexible server.
Parameters
-Name
: The name of the MySQL server.-ResourceGroupName
: The name of the resource group.
Example
Remove-AzMySqlFlexibleServer -Name "myMySQLServer" -ResourceGroupName "myResourceGroup" -Confirm:$false
New-AzMySqlFlexibleNetworkRule
Syntax
New-AzMySqlFlexibleNetworkRule -ResourceGroupName <String> -ServerName <String> -Name <String> -StartIpAddress <String> -EndIpAddress <String> [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
Description
Creates a virtual network rule for an Azure Database for MySQL flexible server.
Parameters
-ResourceGroupName
: The name of the resource group.-ServerName
: The name of the MySQL server.-Name
: The name of the virtual network rule.-StartIpAddress
: The start IP address for the rule.-EndIpAddress
: The end IP address for the rule.
Example
New-AzMySqlFlexibleNetworkRule -ResourceGroupName "myResourceGroup" -ServerName "myMySQLServer" -Name "AllowMyIP" -StartIpAddress "192.168.1.0" -EndIpAddress "192.168.1.255"
Get-AzMySqlFlexibleNetworkRule
Syntax
Get-AzMySqlFlexibleNetworkRule -ResourceGroupName <String> -ServerName <String> [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>]
Description
Retrieves network rules for an Azure Database for MySQL flexible server.
Parameters
-ResourceGroupName
: The name of the resource group.-ServerName
: The name of the MySQL server.
Example
Get-AzMySqlFlexibleNetworkRule -ResourceGroupName "myResourceGroup" -ServerName "myMySQLServer"
Remove-AzMySqlFlexibleNetworkRule
Syntax
Remove-AzMySqlFlexibleNetworkRule -Name <String> -ResourceGroupName <String> -ServerName <String> [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
Description
Removes a virtual network rule from an Azure Database for MySQL flexible server.
Parameters
-Name
: The name of the virtual network rule.-ResourceGroupName
: The name of the resource group.-ServerName
: The name of the MySQL server.
Example
Remove-AzMySqlFlexibleNetworkRule -Name "AllowMyIP" -ResourceGroupName "myResourceGroup" -ServerName "myMySQLServer" -Confirm:$false
Get-AzMySqlConfiguration
Syntax
Get-AzMySqlConfiguration -ResourceGroupName <String> -ServerName <String> [-Name <String>] [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>]
Description
Gets the configuration of an Azure Database for MySQL flexible server.
Parameters
-ResourceGroupName
: The name of the resource group.-ServerName
: The name of the MySQL server.-Name
: The name of the configuration parameter (optional).
Example
# Get all configurations
Get-AzMySqlConfiguration -ResourceGroupName "myResourceGroup" -ServerName "myMySQLServer"
# Get a specific configuration
Get-AzMySqlConfiguration -ResourceGroupName "myResourceGroup" -ServerName "myMySQLServer" -Name "max_connections"
Update-AzMySqlConfiguration
Syntax
Update-AzMySqlConfiguration -Name <String> -ResourceGroupName <String> -ServerName <String> -Value <String> [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
Description
Updates the configuration of an Azure Database for MySQL flexible server.
Parameters
-Name
: The name of the configuration parameter.-ResourceGroupName
: The name of the resource group.-ServerName
: The name of the MySQL server.-Value
: The new value for the configuration parameter.
Example
Update-AzMySqlConfiguration -Name "max_connections" -ResourceGroupName "myResourceGroup" -ServerName "myMySQLServer" -Value "200"
Invoke-AzMySqlRestart
Syntax
Invoke-AzMySqlRestart -ResourceGroupName <String> -Name <String> [-SubscriptionId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
Description
Restarts an Azure Database for MySQL flexible server.
Parameters
-ResourceGroupName
: The name of the resource group.-Name
: The name of the MySQL server.
Example
Invoke-AzMySqlRestart -ResourceGroupName "myResourceGroup" -Name "myMySQLServer"