How to make SQL Server find a login matching the name provided? - sql-server-2008

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

Related

Problems In Connection String with different Users in System for Windows Authentication

Hi this is my Connection String:
Windows Authentication:
<add name="strConnection" connectionString="Data Source=MURALI\SQLEXPRESS;Initial Catalog=Ecowhisk28113;Integrated Security = True" providerName="System.Data.SqlClient;"/>
i run this applications in System's Administrator means working correctly but same application
run in System's Users means I get This Error.
'Cannot open database "Ecowhisk28113" requested by the login. The login failed. Login failed for user 'MURALI\Murali'. '
I want know whether the connection string error or system settings problem...
please help to solve this bug....
Thanks.....
You need to Login to SSMS and grant the users that will be accessing the database proper permissions to the database. You can check this by opening SSMS connecting to the SQL server expanding the Security folder right click on Logins and create a new Login for 'MURALI\Murali'and add the new Login access to the Ecowhish28113 database. You depending on the type of access required you will need to add the login to the database roles in that DB as well.

Cannot connect to local sql server sqlexpress instance via java nor other tools

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.

ASP can't connect to SQL Server database

I'm trying to get a classic ASP application to connect to a local SQL Server 2008 database. The app and database were built by someone else. I'm just trying to get them installed and running on my machine (Windows 7).
I'm getting the following error when when the ASP app tries to connect to the database:
Could not connect to database:
Error Number: -2147467259
Error Message: [ConnectionOpen (Connect()).] does not exist or access denied.
I don't see any messages in the Windows Event Viewer. I'm looking at: Event Viewer->Windows Logs->Application.
It's a fresh database install using a simple restore. The SQL Server install uses the default instance. SQL Server and Windows authentication are both allowed. I left the existing connection string (in the ASP code) in tact and just tried adding that to my SQL Server installation. Here's the connection string:
strConn = "PROVIDER=SQLOLEDB;SERVER=localhost;UID=TheUser;PWD=ThePassword;DATABASE=TheDatabase;"
To add that user to SQL Server, I went to Security/Logins in SSMS and added the user and the password. I selected the database in question as the Default database. I thought that might do the trick, but it didn't. Then, I went into TheDatabase, then went into Security there. I added a new user there, referencing the new user I had already added in server Security. Under Owned Schemas, I clicked db_owner and under Role Members I checked db_accessadmin and db_owner. None of this gave the ASP application access to the database. The sid values match in sys.database_principals and sys.server_principals for the login in question. I am able to login to SSMS using this login.
The app needs to execute selects against the database like this:
oConn.Execute('select * from someTable')
I'm not a DBA and am sort of grasping at straws here. How do I get this thing connected?
Thanks,
Jay
It occurred to me that SQL Server or the website in IIS might be running as users with the wrong permissions. Based on what I read, it's okay for SQL Server to be running as Local System, so I left that alone.
In IIS, my website was using "Application user (pass-through authentication)". This is set in the Basic Settings->Connect As ("Edit Site" dialog box). When I clicked "Test Settings...", next to Authorization it said "Cannot verify access to path (c:\mywebsitepath)." I increased access permissions on that directory, but that didn't help. In the "Connect As" dialog box, I then changed "Path credentials" to use "Specific user" instead of "Application user (pass-through authentication)". I set it to use the user that I log in to my machine as. After that, when I click the "Test Settings..." button, next to "Authorization" it says "Path is accessible (c:\mywebsitepath)." After that, the ASP website is able to connect to SQL Server just fine.
Since the connection string was using a specific SQL Server username and password, I'm not exactly sure why this fixed the problem, but it seems to have.

New SQL Server user failed to login

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

Error in login to SQL Server

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.