Oracle/MSSQL/MySQL

How to reset MSSQL Server SA Password on Ubuntu via the command line and SQL Server Management Studio

When installing a new instance of MSSQL Server in a mixed-mode authentication, you are required to set the password for the SA (System Administrator) account. The SA account is used only for the management of SQL Server.

See this guide on how to download and install Microsoft SQL Server 2019 Express edition and Microsoft SQL Server Management Studio on Windows 10 and Windows Server. How to install Microsoft SQL Server 2019 and MsSQL Command line tools on Ubuntu Linux. You may also want to download the SQL Server 2019 Developer version (Microsoft SQL Server 2019 and Microsoft SQL Server Management Studio which is a full-featured free edition, licensed for use as a development and test database in a non-production environment.

Below are the steps to have the SA password changed via the command-line tool.
– Step 1: Connect to the MSSQL Server using the command-line tool with the command below using the existing password. This is required to ensure the previous password is functional. See the following article on how an SA password is created “how to install Microsoft SQL Server 2019 and MsSQL“.
- Please skip this step if you don’t know the password.

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

Step 2: To change the “SA” password changed, please perform the following steps
– First stop SQL Server service on the Ubuntu Linux

sudo systemctl stop mssql-server

- To ensure the the mssql-server is really stopped, run the command below


sudo systemctl status mssql-server

Step 3: Reset the “SA” password with a new password

/opt/mssql/bin/mssql-conf set-sa-password

Step 4 : Start and verify the status of SQL Server Service is running again.

sudo systemctl start mssql-server
sudo systemctl status mssql-server

Note: If you can access the Ubuntu Linux "MSSQL server" using SQL Server Management Studio (SSMS). You can easily change the change SA password using GUI

- Connect to the database instance using Windows User Authentication.
- Expand the instance.
- Expand Security.
- Expand Logins.
- Right click SA.
- Select Properties.
- Delete the old password and enter the new one.
- Delete the old confirm password and enter the new one.
- Click OK.
- Disconnect from the database instance.

Reconnect to the database instance using the SQL Server Authentication using the user name SA, and the new password

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x