Sql server error 18456 is common issue appear during login process on Microsoft SQL Server. This error can happen when you try to login with local administrator, as well as under the domain administrator and under the sa. Microsoft SQL Server login failed error can be encountered due to varied reasons. Most of the time, an error code comes up with a description that gives a hint about what has gone wrong. But I some cases the error come without any description. In this article, we’ll take a look at the typical reasons of the error 18456 appear on SQL Server during login process and show different ways to solve this error.
The view of error:
“Login failed for user ‘<user_name>’. (Microsoft SQL Server, Error: 18456)”.
How To FIX SQL Server Error 18456
Troubleshoot with Short Solutions
Here, you have some possible reasons:
- The login does not exist or was not typed correctly
- Make sure that the username or password are correct
- The password is incorrect
- The user forgot the password or login
- The Windows Authentication is not in Mixed mode
- A virus resets all the passwords
- A malicious hacker reset the password
- The logins were damaged or the master database is damaged
- The database was migrated, but the logins were not migrated
- The administrator modified the passwords by mistake
- Restart the SLQ Server service
Troubleshoot with State of the Microsoft SQL error 18456
Most of the time the SQL error 18456 come with the severity and state number. A state number might not mean much, yet it can offer more details as to what is wrong and where to look next.
To get a more detailed info about Microsoft SQL Server Error 18456 reason, you need to open the SQL Server error log file – ERROR.LOG. This is plain text file located under folder MSSQL\Log. Below are some states of the error 18456 sql server. The descriptions and potential solutions offer a quick explanation and potential troubleshooting guide.
State | Error Description |
1 | Error information is not available. This state usually means you do not have permission to receive the error details |
2 | Invalid user ID |
5 | User ID is not valid. |
6 | Attempt to use a Windows login name with SQL Authentication |
7 | Login disabled |
8 | Password is incorrect |
9 | Password is not valid |
11-12 | Valid login but server access failure |
13 | SQL Server service paused |
16 | Authorization is correct, but access to the selected database is not allowed |
18 | Change password required |
27 | Initial database not found |
38 | Could not find database requested by user |
102 – 111 | AAD failure. |
122 – 124 | Failure due to empty user name or password. |
126 | Database requested by user does not exist. |
132 – 133 | AAD failure. |
Common Solution for Error 18456
If the issue cannot be resolved from with short solutions above, read below for additional information:
Read also other SQL Server Helping Posts:
Checking the Server Authentication Mode
In this case you are trying to login on SQL Server using sql user. Once we login to SSMS using Windows Authentication, we need to check the security settings to confirm whether MSSQL is set up to allow both Windows and SQL Authentication.
Check and Change SQL Server Authentication Mode from GUI:
- In SSMS, right-click the Server Name at the top of the Object Explorer window and choose Properties.
- Next, click the Security page.
- If you find Windows Authentication is the only mode configured, this is the likely cause of sql server error 18456, Login failed for user ‘’.
- Setting the Server authentication mode to allow SQL Server and Windows Authentication, you will be able to login to MS-SQL with a SQL user and password or a Windows user and password. After making this change, you will need to restart the SQL Server service.
Change SQL Server Authentication Mode from regedit
You can use the registry to modify the authentication mode. Use the regedit to change the registry:
Image (regedit)
- machine\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQLXX.MSSQLSERVER\MSSQLServer
- Change the login mode value.
- 2 is mixed mode.
- 1 is Windows Authentication.
Checking pass expired or login disabled
Check out that the password is not expired.
- Open SSMS, Instance – Security – Logins and find the user that have issue
- On general tab check if the Enforce password expiration and enforce password policy are checked
- Un-check them
Check out that the login is enabled.
- Open SSMS, Instance – Security – Logins and find the user that have issue
- On status tab and check if is selected the “Enabled” option
Reset the Password of the user
If you forget your password, you can ask your DBA to reset your account. The easiest way to reset the password is by using SQL Server Management Studio (SSMS).
- Go to security and Logins:
- Select the login and you can change the password:
- If you do not like to use SSMS, you can use T-SQL to create users and change the password:
USE [master] GOALTER LOGIN [Test] WITH ‘newpasswordtest’GOChange Windows Authentication
So we hope that you fixed the issue with the sql server error 18456.