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"
echo "stopping svr"
sc \\MachineName stop "MSSQLSERVER"  > SvrStop.txt
echo "svr stopped please verify"
echo "starting svr"
sc \\MachineName start "MSSQLSERVER"  > SvrStart.txt
echo "svr started please verify"

All output will be logged in 3 log files namely

You need to have admin rights on the machine

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

No comments:

Post a Comment