SQL Server user account locked out

It's possible that your SQL Server database user gets locked out after multiple failed login attempts.

If you're running Microsoft SQL Server (on-premise) and get locked out of SQL Server, there's a few ways to resolve the problem using tools like SQL Server Management Studio (SSMS), but the command line is the most reliable and relatively easy for a system admin.

The following instructions assume you're running the default "ACCTIVATE" instance of SQL Server. You can swap out "ACCTIVATE" for your instance name if needed. Also, these instructions are written for the SQL Server "sa" user account, but can be adapted for any SQL user account.

  1. We need to launch Windows PowerShell as administrator on the computer running Microsoft SQL Server. Search for Powershell on the Windows Start menu, then click Run as Administrator

  2. First, we need to restart SQL Server in single-user mode for SQL CMD utility. Run these commands in PowerShell:
    NET STOP "SQL Server (ACCTIVATE)"
    NET START "SQL Server (ACCTIVATE)" /f /mSQLCMD
  3. Now, let's run SQLCMD to connect to the database server for maintenance.
    SQLCMD -E -S LOCALHOST\ACCTIVATE
  4. OPTIONAL, but probably a good idea! Reset the SQL user password. Replace newpassword with a strong password of your liking.
    sp_password @new = 'newpassword', @loginame = 'sa' GO
  5. Finally, unlock the user account after the source of the bad login attempts has been identified and resolved.
    ALTER LOGIN sa WITH PASSWORD = 'newpassword' UNLOCK GO
  6. Quit PowerShell, and you should now be able to launch Acctivate.