Blog Post

Reset SA password on SQL Server on Linux

,

This article is about how to proceed when you forgot the password of your SQL Server “sa” account, Password was entered wrong many times then “sa” account got locked, or someone wants to reset the password without using SQL Server management studio (GUI).

The mssql-conf is a configuration tool that installs with SQL Server on Linux (Red Hat Enterprise Linux, SUSE Linux Enterprise server, and Ubuntu). This tool as a replacement for SQL Server Configuration Manager which exists on Windows. 

Resets the sa login password 

  • Connect SQL Server using command-line tool with the existing password (The purpose of this step to show you my current “sa” password. At the end, once I reset the “sa” password, you will see that I shall be using a new “sa” password to connect to SQL Server. If you are dealing with real time issue, you can ignore this step.)

sqlcmd -S <SQLInstanceName>-U <UserName> -P <Password>

  • To change the “sa” password, you have to first Stop SQL Server service which is running on the Linux machine. Let’s stop the SQL Server and verify the status of SQL Server. 
sudo systemctl stop mssql-server
sudo systemctl status mssql-server

  • Reset the “sa” password by key new strong password now.
/opt/mssql/bin/mssql-conf set-sa-password

Note: When you are resetting/changing “sa” password using sqlcmd in a bash terminal,  you need to be escaped or not used the character “$” because it is a special character in bash. 
  • Start and verify the status of SQL Server Service
sudo systemctl start mssql-server
sudo systemctl status mssql-server

  • Let’s connect SQL Server with the new password.
sqlcmd -S <SQLInstanceName>-U <UserName> -P <Password>

You have reset “sa” password successfully ?? without using GUI option.

Keep Learning and exploring SQL Server on Linux!

The post Reset SA password on SQL Server on Linux appeared first on .

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating