SQL Server on Linux: How to Change SA password

SQL Server on Linux: How to Change SA password

Introduction
This article is about how to proceed when you get error message 'Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user 'sa'.. '

Problem Definition  

SA Password is entered wrong more than 3 times then SA account will locked or someone want reset password.


Solution


using mssql-conf setup  need following step:- (this require reboot sql server)

1. Conf setup

you need to stop mssql-server  using this command   -conf setup command 

sudo systemctl stop mssql-server

sudo /opt/mssql/bin/mssql-conf setup

  • Setting up Microsoft SQL Server  
  • Enter the new SQL Server system administrator password:   --Enter strong password here  
  • Confirm the new SQL Server system administrator password: --Enter strong password here  
  • Starting Microsoft SQL Server...  
  • Enabling Microsoft SQL Server to run at boot...  
  • Setup completed successfully.
  • Check Mssql services status using command sudo systemctl status mssql-server

 2. Change password using sp_password 

  • Login with User who having sysadmin access on the server.
  •  syntax: sp_password NULL, ‘<insert_new_password_here>’, ’sa’ 
  • command :-

sp_password NULL, 'Mssql@12345', 'sa'


 3. Using GUI using Window server:-
   a. Connect Linux sql server in Windows server using SSMS.
   bSelect  the Security->Logins folder in the left side of your window; Right-click on “sa” and choose properties;

       change password  and confirm with complexity.