Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How can a lost SA password be reset on SQL Server

Posted on 2014-12-17
7
Medium Priority
?
77 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 1000 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 52

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 1000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

618 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