I set the mode to mixed and created a login for sql server, e.g sql_login_user.
This works and i am able to login to the server and database with the sql_login_user.
I then created a user in the database (readonly_user) and assigned them the "sql_login_user" login. I also selected SQL user with login. The schema was default (dbo).
However, when I try to connect with the user name readonly_user, I get an error - "login faile for user readonly_user..."
I'm fairly certain this worked for me in SQL Server 2014.
ANy help would be appreciated
Related
I am new to using SqlPackage.
I have a powershell command that looks something like
.\SqlPackage.exe /TargetFile:"C:\\Program Files\\Microsoft SQL Server\\150\\DAC\bin\\somefile.bacpac" /Action:extract /SourceServerName:"someServer" /SourceDatabaseName:"someDB" /SourceUser:"someUser" /SourcePassword:"somePassword" /DiagnosticsFile:"C:\\Program Files\\Microsoft SQL Server\\150\\DAC\\bin\\extract-log"
When I run this command I get the error
*** Error extracting database:Could not connect to database server.
Login failed for user "someUser"
I have checked the username and password and they are both correct. I used them to successfully login to SSMS. The user is the admistrator on the server, so should not be an issue with permissions I don't think.
I have followed the instructions to view the logs but under the server I do not have a Management tab. I do not understand why since I am the admin on the server.
Does anyone have any ideas on how I can find the source of the issue?
The reason for this error could be one of many. Without the true authentication error, from the SQL Server logs, it's impossible to state what the solution is, but here are a few possible reasons:
The Connection details are incorrect.
You are using the wrong LOGIN and/or password combination. Check that the creditials are correct against those stored in your password management software.
You are connecting to the wrong instance, and the LOGIN does not exist on the instance. Check that the instance details in your connection string are correct.
The LOGIN you are using is disabled. You need to log onto the server and re-enable it:
ALTER LOGIN someUser ENABLE;
The LOGIN doesn't have the connect permission. YOu need to log onto the server and GRANT it:
GRANT CONNECT SQL TO SomeUser
The LOGIN is trying to connect to a database it does not have a mapped USER on. You will need to CREATE the USER objects in the database(s) it requires access to, along with granting those USERs the needed permissions. You would create the USER with:
USE YourDatabase;
GO
CREATE USER SomeUser FOR LOGIN SomeUser;
There is a server trigger causing an error. Check that there are no triggers that are misbehaving that would cause the authentication to fail.
Another reason that would be exposed in the SQL Server log.
I have a weird problem with SSDT(Visual Studio 2017 server explorer) when I try to view the tables in my Database
In SSMS (SQL Server Management Studio 2017) I created a database with a new user called admin. This user has public and sysadmin permissions and can execute CRUD queries and see the tables in the Object Explorer.
So everything is working fine... However, when I try to connect to the database from VS2017 with SSDT I succeed to connect to the server, but I cant view the tables inside the Server Explorer and it throws me the "Login Failed for user..." error. However when I try the same with the SQL Server Object Explorer it works fine:
Why do i get this error? The credentials are correct otherwise it wouldn't have worked in SSMS and object explorer. My permissions are correct otherwise I wouldn't have been able to create the table and insert data into it. Why do I get the Login failed error in the Server Explorer?
Okay so I managed to fix the "problem",
I was entering the correct credentials, but it was still giving me this error.
So what i tried this time is to eneabled the Save my password checkbox.... and it worked...
I deleted the connection and created a new connection (without checking the Save my password) and again the same error. So i enabled the checkbox again and it worked...
I think when trying to reach for the tables it re-authenticates at the SQL server, and since the checkbox Save my password was not enabled, it didnt have a password to authenticate with.
check your credentials in the properties of the connection
How do I create a User using SQL code to join an SQL Server via SQL Server authentication mode. I used the code
CREATE LOGIN ANNACASSAR
WITH PASSWORD = '';
GO
CREATE USER ANNACASSAR FOR LOGIN ANNACASSAR;
GO
But I get this error:
Cannot connect to moscow\SQLSERVERMSWDEV.
Additional information:
login failed for user ANNACASSAR
(Microsoft SQL Server error 18456)
Set your server to Mixed authentication mode (right-click on the server in SSMS, Properties, Security, SQL Server and Windows Authentication mode, then restart the server).
However, you really should set a password, because it's a real security risk to create a login without a password.
I unknowingly deleted SA user from the SQL Server 2012. Now i cannot be able to connect to the sever. It shows an error :
Cannot open user database. Login failed. Login failed for the user 'username'.(Microsoft SQL Server, Error: 4064)
Now i don't know what to do?
Help me please
Thanks
When ever get this error,we have to create a new user with server authentication to connect the data base
We can create login for data base under security tab-->create new login under it
If you have Windows administator permissions, you can restart SQL Server in single-user mode. Any administrator can then log in locally and fix things.
Give this a shot as a place to start:
Connect to SQL Server When System Administrators Are Locked Out (MSDN)
I have installed SQL Server 2008 R2 on Windows XP.
In installation process I selected 'SQL Server and Windows Authentication Mode'
When I click right button of the mouse in SQL Server Management Studio on Server -> Security tab 'SQL server and Windows Authentication Mode' is selected.
But when I click on my Database -> Properties - View connection properties Authentication Method is set on Windows Authentication.
To my database was added one user1 with password user1.
But I can't log in to my database from C# (Visual Studio 2008) because error occurs:
Login failed for user 'user1' The
user is not associated with a trusted
SQL Server connection
What isn't right ?
When I get:
string connectionStr = #"Data Source=rmzcmp\SQLExpress;Initial Catalog=ResourcesTmp;Integrated Security=True";
I have following error:
{"Cannot open database \"ResourcesTmp\" requested by the login. The login failed.\r\nLogin failed for user 'RMZCMP\rm'."}
rm is my original user name on which I log in to my computer.
When I get rm I have error:
{"Login failed for user 'rm'. The user is not associated with a trusted SQL Server connection."}
again.
Regards
You say a user was created in your database - did you also create a login to your server?
In SQL Server 2005 and up, security is a two-step process:
you first must define a login that enables a user to even log in to that SQL Server
based on that login, you can define user in your individual databases
Also: you're not showing us your connection string, so we can only guess what settings you're using. From the error message, I'm almost guessing you're using Integrated Security in your connection string - but from your other points in the question, it seems you've created a specific user (and possibly a login for that user) - so you don't want to use integrated (Windows) security...
Most likely, your connection string is invalid - or you're missing a login - or both. You need to give us a bit more information for us to be able to really help!
Can you change your Connection string based on :
Connection string.com
Make sure that your installation of SQL Server is successful.
Ex:
If you can create a SQL Server authentication login
You can login using username/password in SQL Server authentication. Use a connection string like:
Data Source=Servername;Initial Catalog=DatabaseName;User ID=user;Password=sa
But
If you can login using only windows authentication there is something wrong in your installation. Use connection string:
Data Source=Servername;Initial Catalog=DatabaseName;Integrated Security=True
Regards!
That error suggests your application is set to log in with "trusted" (i.e. Windows) credentials and that the Windows account that the program is running as doesn't have a login on the server. Based on the way that you phrased the adding of a user, my guess is that it's a SQL login and you should change your connection string to reflect that.
I created user on my machine (where ms sql is installed)
User name is user1 and password too.
I can log on to Ms sql server on this user (user1)
My connection string is:
string connectionStr = #"Data Source = rmzcmp\SQLExpress; Initial Catalog = ResourcesTmp; User Id = user1; Password = user1;";
I user MS SQL Server 2008
rmzcmp is my computer name.
In ResourcesTmp (my database) ->Security ->Users I have: dbo, guest, INFORMATION_SCHEMA, sys, user1, user2
I don't have sa user.
User1 has following permissions:
Schemas owned by this user:
db_accessadmin
db_datareader
db_datawriter
Database role membership
db_accessadmin
db_datareader
db_datawriter
db_owner
Server properties -> Permissions ->Explicit tab:
Connect SQL : Grantor sa, Grant true.
User1 all checkboxes has false
Security tab -> Server authentication : SQL Serve and Windows Authentication mode is selected as I mentioned in earlier post
Regards
This problem occurs if the user tries to log in with credentials that cannot be validated. This problem can occur in the following scenarios:
Scenario 1: The login may be a SQL Server login but the server only accepts Windows Authentication.
Scenario 2: You are trying to connect by using SQL Server Authentication but the login used does not exist on SQL Server.
Scenario 3: The login may use Windows Authentication but the login is an unrecognized Windows principal. An unrecognized Windows principal means that Windows can't verify the login. This might be because the Windows login is from an untrusted domain.
To resolve this problem, follow the steps that apply to your scenario.
Scenario 1: Configure SQL Server in Mixed Authentication Mode.
SQL Server 2012, SQL Server 2008, and SQL Server 2005
Open SQL Server Management Studio. To do this, click Start, click All Programs, click Microsoft SQL Server 200x (where x is the version of SQL), and then click SQL Server Management Studio.
Right-click the server, and then click Properties. See image.
On the Security page, under Server authentication, click the SQL Server and Windows Authentication mode option button, and then click OK. See image.
In the SQL Server Management Studio dialog box, click OK to restart SQL Server.
see http://support.microsoft.com/kb/555332