Solved

How can a lost SA password be reset on SQL Server

Posted on 2014-12-17
7
68 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 49

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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

733 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