Javascript required
Skip to content Skip to sidebar Skip to footer

Azure Sql Database User Change Password

You may have faced scenarios when you need to change the password of your Azure SQL database. In this article, we will explain various ways to change the administrator password of your SQL database.

  • Reset admin password Azure SQL database from Azure portal
  • Reset admin password Azure SQL database using powershell
  • Change Azure SQL database admin password using Azure CLI
  • Change password Azure database user

Reset password Azure SQL database from Azure portal

Using the Azure portal for managing Azure resources is very convenient. You can easily change the password of your Azure SQL database from the Azure portal by following the below steps:

  • Open the Azure portal and sign in to your Azure account.
  • Navigate to your database whose password you want to change.
  • Click on Server Name. Because you have to change the password of your server on which the database is running. Look at the below image for reference:
reset password azure sql database
Reset Password Azure SQL database
  • You will see the option Reset Password. Click on it to reset the password.
change password azure sql database
Reset Password Azure SQL database from Azure Portal
  • Now you can specify a new admin password for your Azure SQL server.
  • While entering the new password, you have to follow the password policy of Azure SQL. You have to follow all the rules, only then your password will be accepted. The rules are shown below in the image:
change admin password azure sql database
Specifying new admin password
  • Once your new password is accpeted, you have to re-enter the new password.
  • After the password is matched, the Save button will be enabled. Click on Save button to change the password.
  • Now you can login into your Azure SQL database using the new password.

In this way, you can change password of your Azure SQL database from the Azure portal.

Read How to create SQL authentication user in Azure SQL database

Reset password Azure SQL database using Powershell

Microsoft Azure has created a module called Az module which you can use to manage the Azure resources from the PowerShell.

You can either use the Azure PowerShell from the portal where the necessary modules are already installed or you can use the Windows PowerShell. If you want to use Windows PowerShell, you have to install this Az module.

Once you have installed the Az module, you can follow the below steps to change the administrator password of your Azure SQL database:

  • Run the Windows PowerShell as an administrator.

Note: Open the link shell.azure.com and switch the terminal to PowerShell to use the Azure PowerShell.

  • Write the below command to connect your Windows PowerShell to your Azure account:
          Connect-AzAccount        
  • You will see a sign in prompt for signing in to the Microsoft account. Sign in to your Microsoft account. Once you have signed in, you will see an output like in the image below:
azure sql db change password
Connected to the Microsoft Account
  • Now write the below script to change the Azure SQL database password:
          $password = ConvertTo-SecureString -AsPlainText -Force '*********' Set-AzSqlServer -ResourceGroupName GroupAzure -ServerName mysql1000 -SqlAdministratorPassword $password        
  • In the above script, the $password is a variable into which we are storing our new password in the form of a secure string.
  • Set-AzSQLServer is a command line utility to set the Azure SQL server properties. We are using this utility to change the password.
  • GroupAzure is the resource group name and mysql1000 is the server name on which the database is running.
  • Once you execute the above query, your password will be changed and you will see an output like in the below image:
azure sql database reset admin password
Azure SQL database password is changed

Thus, you might have learned how to change the Azure SQL database password from PowerShell.

Read Backup and restore SQL Server to Azure Blob storage

Change Azure SQL database password using Azure CLI

In this section, we will discuss how to change the Azure SQL database password using Azure CLI. You can follow the below steps to change the Azure SQL database password:

  • Open the link shell.azure.com in your browser and sign in to your Azure account.
  • Make sure the terminal is in bash mode. Look at the below image for reference:
change admin password azure sql database from cli
Switching to bash terminal
  • Now execute the below command in the terminal to change the Azure SQL database administrator password:
          az sql server update --resource-group GroupAzure --name mysql1000 --admin-password Kushal@123        
  • In the above command, we have used the az module that is used to manage the Azure resources from the command line. GroupAzure is the name of the resource group, mysql1000 is the name of the SQL server instance and Kushal@007 is the new admininsrator password for the database.
  • You will see an output like in the below image after executing this command and your password will be changed.
reset password azure sql database azure cli
Password Changed

Hence, in this way you can use the Azure CLI to reset the administrator password of your Aure SQL database.

Thus, you might have learned how you can change the administrator password of your Azure SQL database in multiple ways.

Read Cannot open backup device operating system error 50 azure

Change password Azure database user

In the above sections, we explained how you can change the administrator password of your Azure SQL database. Now we will explain how you can change the password of a user in the Azure SQL database.

For the demonstration purpose, we have created a user in our Azure SQL database. The username is TestUser and the password for this user is User@123.

          CREATE USER [TestUser] WITH PASSWORD = 'User@123'; ALTER ROLE [db_datareader] ADD MEMBER [TestUser];        

Now suppose you want to change your password. You can use the ALTER USER statement to alter the various information about the user like username, password, schema, etc.

If you are logged in as the user TestUser, you can change the password for the user TestUser, by executing the ALTER USER statement as:

          ALTER USER [TestUser] WITH PASSWORD = 'Password@123' OLD_PASSWORD= 'User@123'        

Now the new password will be Password@123.

Ezoic

You may like:

  • How to rename a database in Azure SQL
  • SQL Server stored procedure if exists update else insert
  • SQL Server check user permissions on table
  • How to execute stored procedure in SQL Server
  • Azure sql password validation failed
  • How to check if SQL Server is running
  • Read only replica Azure SQL

In this way, you can change password of an Azure SQL database user.

  • Reset password Azure SQL database from Azure portal
  • Reset password Azure SQL database using powershell
  • Change Azure SQL database password using Azure CLI
  • Change password Azure database user

Azure Sql Database User Change Password

Source: https://sqlserverguides.com/reset-password-azure-sql-database/