Login failed for UserX with SQL

When attempting to connect to a SQL data source, you may encounter the following error message: (0x80131904): Login failed for user 'UserX'.

This typically indicates that the account has been locked after multiple unsuccessful login attempts. Whether this occurs depends on the SQL Server’s configured password policy.

Solution

Check if the account is locked

To confirm whether the SQL account is locked, run the following query:

SELECT LOGINPROPERTY('UserX','islocked')

A result of 1 means the account is locked.

Unlock the account

You can unlock the user account in one of two ways:

Option A: Using SQL Server Management Studio (SSMS)

To manually unlock the user, open the user’s properties, navigate to the Status tab, and uncheck Lock SQL user. Then, update the password as needed and apply the changes.

Option B: Using a T-SQL command

Alternatively, run the following SQL command to unlock the account and reset the password:

ALTER LOGIN [SQLID] WITH PASSWORD = 'NewSecurePasswordHere' UNLOCK 

Replace 'NewSecurePasswordHere' with a strong password that meets your organization's security requirements.

To learn more, visit the official Microsoft SQL Server documentation.

Devolutions Forum logo Donnez-nous vos commentaires