Solved

How can a lost SA password be reset on SQL Server

Posted on 2014-12-17
7
61 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
Comment Utility
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 45

Expert Comment

by:Vitor Montalvão
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Jack Seaman
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now