Skip to main content

Microsoft sql server Error:18456 login failed for user

In this bog post I will show you reasons why you might be getting SQL Server error 18456 and show you may be able to solve it.

Previously I was Explained about  Microsoft SQL Server 2008 Error:233 - Solution Unable to connect SSMS, Microsoft SQL Server, Error: 53 ,SQL Server 2008 R2 Setup Error - is not a valid login or you do not have permission .

Contents
  • 18456 Error Overview
  • SQL Server Authentication not enabled
  • Invalid login name
  • Invalid password
  • Common reasons
  • State 1 explanations

Before you start: If this article doesn't not help you find the reason, solution or you solve it in another way than please let me know  so I can update the article. Remember you need sufficient permissions in order to make certain changes.

18456 Error overview

When connecting to Microsoft SQL Server and trying to use usually SQL Authentication method you may get event ID error 18456 login failed for user you provided. See below example.

 Microsoft sql server error 18456 login failed for user


This usually means that your connection request was successfully received by the server name you specified but the server is not able to grant you access for a number of reasons and throws error: 18456. This eventID sometimes provides also state 1 which actually isn’t that useful as due to security reasons any error is converted to state 1 unless you can check logging on the server. Microsoft does not provide very useful message boxes so below are some explanations why you get the error.

Below is a list of reasons and some brief explanation what to do:

SQL Authentication not enabled: If you use SQL Login for the first time on SQL Server instance than very often error 18456 occurs because Windows Authentication (only) is set in Server properties (security section).
To Access Server Properties, Open SSMS, go to Object Explorer pane (use view if you can't see it). Use the connect button to connect to database engine for your server. Once connected you will see it in object explorer. Right click server and click properties. Server Properties window will appear.
microsoft sql server error 18456 login failed for user server properties
See below screenshot that might be causing SQL login to fail

18456 windows authentication
You should set Server Authentication to SQL Server Windows Authentication Mode (see below). Once you select SQL Server Authentication you have to restart the server.

18456 sql authentication
Restart required: You have to restart the service when you change server authentication but bear in mind if someone hasn't restart the service this might be the reason why you get 18456. Remember service restart should be carefully planned on production servers as it will clear certain information (cache) and may impact performance of the server.
NOTE: I recently tried to restart service using SSMS 2012 on Windows 7 and it didn't work.... actually the message below was hidden behind SSMS window and I just did not see it so ensure you get this message when you decide to restart the service. 
18456 restart required

Invalid userID: SQL Server is not able to find the specified UserID on the server you are trying to get. The most common cause is that this userID hasn’t been granted access on the server but this could be also a simple typo or you accidentally are trying to connect to different server (Typical if you use more than one server)

Invalid password: Wrong password or just a typo. Remember that this username can have different passwords on different servers.

less common errors: The userID might be disabled on the server. Windows login was provided for SQL Authentication (change to Windows Authentication. If you use SSMS you might have to run as different user to use this option). Password might have expired and probably several other reasons…. If you know of any other ones let me know.

18456 state 1 explanations: Usually Microsoft SQL Server will give you error state 1 which actually does not mean anything apart from that you have 18456 error. State 1 is used to hide actual state in order to protect the system, which to me makes sense. Below is a list with all different states and for more information about retrieving accurate states visit Understanding "login failed" (Error 18456) error messages in SQL Server 2005
 
ERROR STATEERROR DESCRIPTION
State 2 and State 5Invalid userid
State 6Attempt to use a Windows login name with SQL Authentication
State 7Login disabled and password mismatch
State 8Password mismatch
State 9Invalid password
State 11 and State 12    Valid login but server access failure
State 13SQL Server service paused
State 18Change password required

I hope that helped you solve you 18456 error. If you know of another cause and solution than let us know and we will include it in the blog post.

Comments

Popular posts from this blog

ASP.NET e-Commerce website GridView with Product Listing

Introduction : E-Commerce web applications are everywhere these days, and many share a common set of functionality. In this article, I will show how to use the GridView and ListView controls to build a powerful product page with many of the features found on today's e-commerce sites. We'll build a bicycle store product grid using some free clip art bicycle images. The example files are user controls which can be easily added to a page. We're only using three images here to keep the size of the sample application small. In previously I was explained about  Sending Email from Asp.net With Dynamic Content  ,  How To Export gridview data to Excel/PDF , CSV Formates in asp.net C#  , How to print Specific Area in asp.net web page How To- Search records or data in gridview using jQuery  . A shopping cart application would require to display the products in a multi column grid, rather than a straight down list or a table. The each item in a product grid would have

How to hide url parameters in asp.net

There are different ways to Hide the URL in asp.net , you can choose any one from bellow options . Previously I was Explained about the  Difference between Convert.tostring and .tostring() method Example  ,   Reasons to use Twitter Bootstrap , How to Register AJAX toolkit in web.config file in asp.net a) Using Post Method b) Using Of Session . c) URL Encoding & decoding process . d) Using Server.Transfer() instead of Response.Redirect() method (1)Use a form and POST the information. This might require additional code in source pages, but should not require logic changes in the target pages (merely change Request.QueryString to Request.Form). While POST is not impossible to muck with, it's certainly less appealing than playing with QueryString parameters. (2)Use session variables to carry information from page to page. This is likely a more substantial effort compared to (1), because you will need to take session variable checking into account (e.g. the

Nested GridView in ASP.NET Using c# with show/hide

In This example shows how to create Nested GridView In Asp.Net Using C# And VB.NET With Expand Collapse Functionality. Previous post I was Explained about the   ASP.NET e-Commerce website GridView with Product Listing  ,  How To Export gridview data to Excel/PDF , CSV Formates in asp.net C# , Sending Email from Asp.net With Dynamic Content  ,  SQL Server- Case Sensitive Search in SQL Server I have used JavaScript to Create Expandable Collapsible Effect by displaying Plus Minus image buttons. Customers and Orders Table of Northwind Database are used to populate nested GridViews. Drag and place SqlDataSource from toolbox on aspx page and configure and choose it as datasource from smart tags Go to HTML source of page and add 2 TemplateField in <Columns>, one as first column and one as last column of gridview. Place another grid in last templateField column. Markup of page after adding both templatefields will like as shown below. HTML SOURCE < a