Change SQL password from command prompt 8


You can change the password from Microsoft SQL Manager very easy but what if this utility does not exist on the target machine how can we change the password for SA user?

Another way is to change SQL password from command prompt.

To update the password for a SQL Server Instance you have to follow the next easy steps:

STEP 1: Open command prompt as Administrator

Vista or Windwows 7: Start\[type] cmd\[right click]\[run as administrator]

WINDOWS XP: Start\run\[type] cmd\[Enter]

STEP 2: change the folder to : c:\Program Files\Microsoft SQL Server\100\Tools\Binn with the following command:

cd “c:\Program Files\Microsoft SQL Server\90\Tools\Binn” [press Enter]

Note:

On some machines the path can be c:\Program Files\Microsoft SQL Server\100 or

c:\Program Files\Microsoft SQL Server\80; Figure out by yourself where you can find the osql.exe utility

STEP 3: run the utility osql.exe with the following command

osql -S localhost\[your instance name] –E

STEP 4: type the new password like in the following command

sp_password NULL, ‘mynewpassword’, ‘sa’ [press ENTER]

STEP 5: type the GO command:

go [press Enter]

STEP 6: exit from osql utility

exit [press Enter]

Congratulations! You have changed the SQL Server instance password with a new one.


About Ionut Afloarei

Senior .Net Developer with 14+ years of experience in Microsoft Technologies (ASP.net/C#, MVC, MSSQL, Entity Framework, Visual Studio, TFS, IIS, Azure Cloud, Microsfot Dynamics).


8 thoughts on “Change SQL password from command prompt

Comments are closed.