I made the following settings on my SQL Server 2012 as suggested in many tutorials:
I set the server authentication to "SQL Server and Windows Authentication mode"
I set a strong password with enforced password policy with default database "master" to SA user
I granted the SA user permission to connect to database engine and
enabled his login.
Yet when I try to login to the "localhost"
through the SQL Server Authentication.
it fails with:
Cannot connect to (local).
------------------------------
Login failed for user 'sa'. (Microsoft SQL Server, Error: 18456)
Only possible way how can I login is still the Window authentication.
My instance is named MSSQLSERVER. localhost\MSSQLSERVER is inaccessible.
There could be multiple reasons. Please check your error log and find the state of error. Depending upon the state, error could be -
State Description
1 Error information is not available. This state usually means you do not have permission to receive the error details. Contact your SQL Server administrator for more information.
2 User ID is not valid.
5 User ID is not valid.
6 An attempt was made to use a Windows login name with SQL Server Authentication.
7 Login is disabled, and the password is incorrect.
8 The password is incorrect.
9 Password is not valid.
11 Login is valid, but server access failed. One possible cause of this error is when the Windows user has access to SQL Server as a member of the local administrators group, but Windows is not providing administrator credentials. To connect, start the connecting program using the Run as administrator option, and then add the Windows user to SQL Server as a specific login.
12 Login is valid login, but server access failed.
18 Password must be changed.
For detailed information - MSDN
Related
I installed SQL Server 2008 Express on Win 7 64. I can connect to it via SQL Server Management Studio using Windows Auth, but not SQl Server Auth. Following the directions in http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/, I feel I have properly configured for remote connections & sql server auth. Yet, when I try to login, I get an error stating that the login failed. Googling hasn't seemed to help for the answers do not make sense, do not seem to apply. One of these was a suggestion to change the dynamic port to blank, hard code the port. Since this tool is by default not installed in such fashion, I have a hard time believing this is the actual problem. Not one post I found explained why that should be changed.
The exact message is:
Cannot connect to bvl-wd-bturner\SQLEXPRess
Additional information:
Login failed for user 'DTN\bill.turner'. (Microsoft SQL Server, Error 18456)
I attempted to login with the following credentials:
Server type: Database Engine
Server name: bvl-wd-bturner\SQLEXPRESS
Authentication: SQL Server Authentication
Login: DTN\bill.turner
Password:
For what its worth, logging on using Windows auth, I look at the connection properties. The User Name complies with the login above. The Server Name is the same (in fact copy/pasted to be sure for both).
=== UPDATE ===
Windows Firewall is off.
I tried also, even with my reservations, to hardcode the port number, removing the "0" on all dynamic ports and setting the port to 1433. No luck. :-(
=== UPDATE 2 ===
I realized I needed to create a SQL Server account and have done so. I can now log in via SSMS with the following credentials. However, I seem to be unable to login through DbVisualizer or a test java file with the follow:
Driver is net.sourceforge.jtds.jdbc.Driver
Connection url is jdbc:jtds:sqlserver://bvl-wd-bturner:1433/host
The credentials I now use successfully in SSMS are:
Server type: Database Engine
Server name: bvl-wd-bturner\SQLEXPRESS
Authentication: SQL Server Authentication
Login: local
Password:
At this point I have to believe it is something obvious I am missing, but have yet to find it.
The login: DTN\bill.turner looks like a Windows login, not a SQL server login which has no domain component. Is DTN your domain name? If so, providing this with the SQL login will probably confuse the client into trying windows authentication, which will then fail if the login doesn't exist.
What is the name of the SQL server login that you have created (within the SQL management studio)? It shouldn't have a domain\username format, it should just be a username on its own. You also need to make sure that you select SQL authentication when connecting.
Try adding your current logged in account (Windows) to the Local Administrators group on your computer.
The link posted at the beginning,
http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/
Plus this article on setting the default log on database:
http://blog.sqlauthority.com/2008/11/04/sql-server-fix-error-4064-cannot-open-user-default-database-login-failed-login-failed-for-user/
Solved this problem for me. Hopefully it will help others who wind up here.
I've created new user in SQL Server Management Studio (SQL Server 2008 Express) in security tab.
Specified the login name, SQL Server authentication, entered a password, assigned server role sysadmin, mapped to my database and there specify it as db_owner. Also in database security is specified in tab Schemas owned by this user is db_owner.
I've checked a lot of tutorials but all of them do the same as me but when I try to login to SQL server (even manually) error message is thrown:
Login failed for 'MyUser' (Microsoft SQL Server, Error: 18456)
Any idea what's wrong?
Thanks a lot.
Peter
Failed to login SQL Server after installing SQL Server and creating new login user for SQL Server? You can check error description in Error Log file at first. Look for entry and then confirm what "State" means in entry.
After making sure which lead to this SQL Server login error, take appropriate measures. Generally, you would need to do according to different situations.
You would need to change authentication mode to Mix Authentication or SQL Server Authentication mode.
You would have to enable SQL login user if the login is disabled.
Reset SQL Server user password if the login user password is incorrect.
Configure Windows Firewall to allow SQL Server access if the login is valid but server access is failed.
More details about fixing failed login error for user, you can refer to this article.
http://www.isunshare.com/sql-server/fix-sql-server-failed-login-error.html
I came across the same problem and solved mine by changing the Server to Mixed Authentication Mode. In my case, I was trying to log in with a SQL server login, but the server was only set up to accept Windows Authentication.
See this link for how to change it:
http://support.microsoft.com/kb/555332
I realise this question is old, but I hope the answer helps someone.
Thanks
I have been trying all kinds of tricks - from enabling TCP/IP, adding exception to firewalls to poking bill gates vodoo doll. But nothing seems to work for me. Is it really that difficult to connect to sql server 2008 via management studio ? Maybe, robbing a bank would be easier.
While i figure out which bank to rob, can you help me to fix the problem ?
When I try to login to sql server 2008, this is the error i get-
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)
The links i tried so far -
blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/
and some more random links on the net.
When you installed SQLServer, there are several options that may affect the way SQLServer runs and how you have to connect to it. The link you included in your question that points to the sqlauthority blog has an additional thread posted by Vince. Be sure to follow those instructions so that SQLServer will be set to listen on port 1433 and not a dynamic port.
Also, when you log-in, if it tells you that the login fails (e.g., for xxx\yyy), then you probably missed the option in the install to add the current user as an authorized users. In that case, you will have to log in through SSMS using SQL Server Authentication, and provide sa as the username and the password that you set during the install.
After you log in, you can add your Windows user account to the list of authorized users by expanding the root Security folder in the SSMS object explorer, right-click Logins and select New Login. From there you can search for your user account and add a Windows authentication user. That will make it possible for you to log in using Windows Authentication so you won't have to type your password every time you launch SSMS.
When I want to connect to SQL Server 2008, I get this message:
Cannot connect to server.
Additional Information: Cannot open user default database. Login failed. Login fail for user 'sa'. (Microsoft SQL Server. Error:4064)
How do I resolve this error?
This error (Microsoft SQL Server.Error:4064) occurs when the database which is dropped is default for some database user.
When the user tries to login and their default database is dropped the error shows up.
Cannot open user default database. Login failed. Login failed for user
‘UserName’. (Microsoft SQL Server, Error: 4064)
The way to resolve this is given here, summarized below.
The solution to log on is:
From the Connect to Server dialog, click Options
Change value of Connect to database: to any valid database on the server
The permanent solution to fix the server is to run SQL like:
ALTER LOGIN [test] WITH DEFAULT_DATABASE = master
GO
In my case this was due to a user being a member of multiple groups, each group having its own login. All groups' logins need to have their default database set to a database accessible to the user.
Other possible problems are listed at https://support.microsoft.com/en-us/kb/307864.
You can set each login with an invalid default database to have a default database of master (accessible to all logins):
alter login [loginname] with DEFAULT_DATABASE = master
The user default database is unavailable at the time of connection so that this error message will popup .SO check which server you tagged to that particular user to access whether it is online or offline mode.
I have just restored a database backup to my local SQL Server express instance.
In management studio under the server instance node I went to: Security -> Logins -> New login...
Then I filled in a login name, password and chose SQL Server authentication. And at the bottom I selected the newly restored database to be the Default database.
At the User Mapping 'tab' at the left, I mapped the user to the newly restored database and gave it "db_owner" role.
When I try to login the following error is given in the log:
Login failed for user 'username'. Reason: Could not find a login matching the name provided. [CLIENT: ]
How can I make SQL Server find the login matching the name I provided?
Other info:
Named pipes are enabled
TCP/IP is enabled
Remote connections are allowed
Please make sure you have selected "SQL Server Authentication" mode for user you created from
Server > Security > Logins option.
Another possibility, is that you created the SQL Server login using Management Studio, and the option requiring the user to change the password on first login was checked. If you didn't immediately login with Management Studio, and change the password, then the attempt to login from the other machine is not able to pop up a dialog box to change the password and so it fails.
try it by removing user and create again.
This is old but for some one who encounters error for ASP.Net Core 2.2 using EF core and VS Code, I got error
Error Number:18456,State:1,Class:14
Login failed for user 'sa:password=MyPassword'.
I looked logs from SSMS and found error as
Login failed for user 'sa:password=MyPassowrd'. Reason: Could not find a login matching the name provided. [CLIENT: MyIp]
After searching here and there i found that I have to add Persist Security Info=False in connection string, so my connection string became like
"Default":"Persist Security Info=False;User ID=sa;Password=MyPassword;Initial Catalog=MyDb;Server=MyServerIp"
I found this format from Microsoft Docs. After that it worked fine.
persist security info=false is default. I didnot found any reason why my connection string without it was not working. From here