Wednesday, May 7, 2014

How to Recover SA Password in Single-user Mode

Forgot your SA password and can't connect to SQL Server? How to login to SA account after locked out of SQL Server? Start SQL Server in single-user mode and you can reset SQL Server password easily. This hacking trick makes it possible to unlock SQL Server login without resetting the password of any existing account.

How to Recover SA Password in Single-user Mode
  1. Launch SQL Server Configuration Manager. Stop your SQL Server instance if it is running.
  2. Right-click on your SQL Server instance and select Properties.
    SQL Server Configuration Manager
  3. In SQL Server 2014 or 2012, click Startup Parameters tab. Enter –m and then click Add.
    SQL Server 2014/2012 Startup Parameters
    If you've installed SQL Server 2008 (R2) or an earlier version, click Advanced tab and add -m; before existing value in Startup Parameters box, without any spaces.
    SQL Server 2008/2005 Startup Parameters
  4. Save your changes and restart the SQL Server instance. This will start SQL Server in single-user mode.
  5. Open an elevated Command Prompt and use the SQLCMD command to connect to your SQL Server instance:
    SQLCMD –S .\SQLEXPRESS
    Replace SQLEXPRESS with the name of your SQL Server instance.
  6. Here we'll create a new login called "tom" and then add this account to the SA server role. Run this command:
    CREATE LOGIN tom WITH PASSWORD='P@ssword123'
    GO
    SP_ADDSRVROLEMEMBER tom,'SYSADMIN'
    GO
    Create New Login in SQL Server Single-user Mode
  7. Once you've successfully performed these steps, the next step is to stop your SQL Server instance. Remove the -m you've added in Startup Parameters.
  8. Start your SQL Server instance. Open the SQL Server Management Studio and you can login using the newly created "tom" account. You now have SA access to your SQL Server instance. You may now reset the SA password and take control of your SQL Server box.
However, if you can't access SQL Server in single-user mode or can't log on Windows as administrator, this method won't work. In that situation, you need to use the SQL Server Password Changer program which enables you to unlock / reset SQL Server SA password offline.

1 comment:

  1. Sql Password Recovery recover lost password from SQL Server database. The software is primarily designed for those users who are facing difficulty in accessing SQL SA password.

    ReplyDelete