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.)

  • 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. 

  • Reset the “sa” password by key new strong password now.

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

  • Let’s connect SQL Server with the new password.

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

Keep Learning and exploring SQL Server on Linux!

2 thoughts on “Reset SA password on SQL Server on Linux

  • Dave

    The first sentence says: “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 …”

    The first step says: “Connect SQL Server using command-line tool with the existing password …”

    How is it possible to connect with the existing password if it was forgotten or the account is locked?

    Reply
    • Dharmendra
      Dharmendra

      Thanks Dave for your valuable input! My intension was show the current password and then the new password of the “sa” account. Now, I have modified my wording to make it more clear…..

      Yes, you are right. Once we forgotten or locked the “Sa” account, we cannot connect to SQL Server.

      Reply

Leave a comment

Your email address will not be published. Required fields are marked *