Monday, June 18, 2012

How to change SQL server service account and password

Create a .BAT file using following script

MachineName is your server name
domain\account is account you want to set for SQL server service account
Pwd1234 is new password

Step 1 is to change credentials
Step 2 is to stop the service since changes do not take effect unless service is restarted
Step 3 is to start the service

Put this code in a batch file and run it from command prompt.

echo "changing pwd"

sc \\MachineName config "MSSQLSERVER" obj= domain\account password= Pwd1234 > ChangePwd.txt
echo "pwd changed"
pause
echo "stopping svr"
sc \\MachineName stop "MSSQLSERVER"  > SvrStop.txt
echo "svr stopped please verify"
pause
echo "starting svr"
sc \\MachineName start "MSSQLSERVER"  > SvrStart.txt
echo "svr started please verify"
pause

All output will be logged in 3 log files namely
ChangePwd.txt
SvrStop.txt
SvrStart.txt

You need to have admin rights on the machine

For details on SC (service controller) utility please check following link

http://technet.microsoft.com/en-us/library/bb490995.aspx

No comments:

Post a Comment