Solved

How can a lost SA password be reset on SQL Server

Posted on 2014-12-17
7
66 Views
Last Modified: 2015-03-03
I've been handed a SQL Server 2008 to maintain.  The previous admin has "lost" the SA password.  No other accounts on the database server have SA privilages.  I want to gain SA access to the database server.  I've read but never done the following:
1. Stop the sql server services.
2. Start the sql server instance in single-user mode:  SQLServr.exe -m
3. Connect to the instance:  SQLCMD -S <Server_Name\Instance_Name>
4.  Create a login: 1> CREATE LOGIN 'Login_Name>' with PASSWORD='<Password>'
                                 2> GO
5. Give the user SA rights:  SP_ADDSRVROLEMEMBER '<Login_Name>','SYSADMIN'
6. Stop the sql server services.
7.  Restart normally.

Is this the correct procedure?  Any suggestions?

There is one production database on this server.  The transaction log is about 36GM and the database is about 600MB.
I will tackle that once I gain SA rights.
0
Comment
Question by:Jack Seaman
7 Comments
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 250 total points
ID: 40505815
That seems correct, you need to make sure that the you start the command prompt as administrator and run the statements 2 and 3.
0
 
LVL 48

Expert Comment

by:Vitor Montalvão
ID: 40506492
No, is not correct at all. if it was that easy what kind of security SQL Server is offering to us?
If you lost the SA password and no one more has SysAdmin permission on the instance you can try to connect with the SQL Server account (if it is a domain account) otherwise you can't do nothing but reinstall the SQL Server.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 40575902
No, is not correct at all.
You may want to double check that.

Here is a good article on the subject:
Disaster Recovery: What to do when the SA account password is lost in SQL Server 2005
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:Jack Seaman
ID: 40635769
I was able to stop the SQL Server and restart it in single user mode using: NET START MSSQL$<instancename> /m

I was able to use Sqlcmd -S <Server_Name\Instance_Name>

Then I tried this to create a user and assign sysadmin to it.
1>      CREATE LOGIN ‘Jack’ with PASSWORD= ‘*********’
2>      GO

1>      SP_ADDSRVROLEMEMBER ‘Jack’,’SYSADMIN’
2>      GO

But the user was not created.
How do I fix this one.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
ID: 40636632
This
CREATE LOGIN ‘Jack’ with PASSWORD= ‘*********’

Would have caused the following error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'Jack'.

The syntax to create a  Login (not a User) is as follows:
CREATE LOGIN Jack with PASSWORD= ‘YourPasswordGoesHere’
0
 

Author Comment

by:Jack Seaman
ID: 40641803
Thanks.  But now I cannot connect using Sqlcmd -S <Server_Name\Instance_Name>
I am at a loss to figure out why.
0
 

Author Comment

by:Jack Seaman
ID: 40641872
I was finally able to connect and create a user and give that user sysadmin rights.

Used this:
CREATE LOGIN [Jack2] WITH PASSWORD=N'********', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
EXEC master..sp_addsrvrolemember @loginame = N'Jack2', @rolename = N'sysadmin'
GO
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question