Sql-server – SQL Server 2008 R2 – Error 18456 State 12 – nothing I find helps me

sql serversql-server-2008-r2

First off let me state that I'm not a DBA, I don't have access to a DBA, I'm just a programmer who has to get a CMS working. I'm generally pretty good at getting random servers working, but this is doing my head in.

I have a trail of SQL Server 2008 installed, with a database that I imported from a backup. The CMS starts up, connects to the DB but tells me

[SqlException (0x80131904): Login failed for user 'kentico'.]

Checking the logs shows me

Error: 18456, Severity: 14, State: 12.

I googled it, and every answer has state 11 and 12 in lumped together, and I think I've done what is mentioned in the posts. but really im just stumbling in the dark. I don't even know what other information I can provide that will help people help me!

I have created a user in in the \security\logins folder, and this login is mapped to a user of the same name in the \databases\<db_name>\security\ folder. What else do I have to do?!

I should say that changing the connection string to the sa account gets me in to the cms, but then I'm only allowed one connection on the sa account so the CMS randomly spits the dummy when the connection is refused.

Any help would be greatly appreciated, and please remember, this is my first time I've even looked at SQL Server, so the assumed knowledge is just not there šŸ™

Best Answer

SQL Server operates in 2 security modes: "Windows" or "Mixed"

Ensure you are set to "Mixed" as per this MSDN article: How to: Change Server Authentication Mode

The clue is in the error:

  • Login failed for user 'kentico' is not the same as Login failed for user 'DOMAIN\kentico' which means a SQL login (not Windows)
  • Error 18456 is for Windows logins

Ergo, your mode is wrong...

Our very own Aaron Bertrand has a good article on the error 18456 states