SQL Server Login Failed for User SA - sql-server

I just logged in to SQL Server 2005 with SQL Server Authentication but was stuck at the error message saying "Login failed for user ‘sa’, (Microsoft SQL Server, Error: 18456)". What happened to this?

In SQL Server Management studio right click in Object Explorer and ensure in the server properties - under Security the option "SQL Server and Windows Authentication mode" is enabled
If you are accessing the SQL Box remotely ensure the TCP/IP setting is enabled in SQL Server configuration manager.

Three things to check if you can't log in to SQL Server using the sa account:
1.Check the password and provide a new one if necessary
sp_password NULL, 'mypassword', 'sa'
2.Enable the sa account
ALTER LOGIN sa ENABLE
3.Check that the sa account is not being affected by the domain security policy
ALTER LOGIN [sa] WITH PASSWORD='yourpassword',CHECK_POLICY=OFF

Related

Bad T-SQL code for account creation

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.

Unable to create database in SQL Server 2008 R2

I have Microsoft SOL Server 2008 R2 on my server. When I am trying to open SOL Server Management Studio as administrator and creating new database, I get this error message
create database permission denied in database 'master' error 262
Also when I am adding sysadmin in login property window section in my login. Then this message appeared:
add member failed for server role 'sysadmin'
Please let me know how to add admin permission on my login and easily to create database
you need to login with SQL server authenticaton for craeting DataBase.
If you are using Windows Authentication then you need to run SQL server as Run As Adminstrator to avoid this error.
Further details Here People Having similar error
Login to your workstation as an administrator and execute the following query
EXEC sp_addsrvrolemember 'Domain\User', 'sysadmin';
CheckHere
Sql Server will not consider if you are admin to your workstation ,but you have to explicitly
make user as a sysadmin.
Intresting

Remote connection to SQL Server 2012 Express

To clarify this in the start. I don't have much experience with SQL Server so every help will be appreciated.
I have a task to set up some program with a SQL Server Express database which is located on a remote server. The database is, as far as I know, configured and should be working. This is the information I have to connect to the database:
IP: xx.xxx.xxx.xxx
The administrator password is 'somepassword'
The SA password is 'anotherpassword'
I think this info is incomplete because there is no username. But what worries me is that I don't get feedback that my password or username are incorrect. Instead I get the error:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server...
I'm using SQL Server Management Studio to connect to the database (SQL Server 2012 Express) and I added an exception in firewall for Management Studio.
And what is the difference between administrator and SA (system administrator) password?
The message you are receiving basically means "I can't connect to SQL Server". It can be due to a number of issues:
The SQL Server service is not running
The SQL Server instance is not configured to use TCP/IP to communicate
The database is using windows authentication and the user is not authorized or
The database is using mixed-mode authentication and the user/pass is incorrect
As for the usernames you are given, I would assume that the "administrator" username is local windows administrator of the machine SQL server is running on, and that the "sa" user is the default database administrator, that is installed when setting SQL Server to use mixed-mode authentication.
So, I would recommend to try connecting to the database using Mixed-mode authentication, with the username "sa" and the "anotherpassword" password.

SQL server 2008 login issue

Hi I created a new login SQL server authentication in SQL server 2008, however I am unable to login with that user.
Getting an error like ,
TITLE: Connect to Server
Cannot connect to (local).
ADDITIONAL INFORMATION:
Login failed for user 'sa'. (Microsoft SQL Server, Error: 18456)
The error Login failed for user 'sa' means that connection to server was established, but server refused it under certain circumstances, such as:
Wrong password
Sql server uses only Windows Authentication (needs server restart)
In your Connection String you ask to connect to specified DB, which is not exists
sa login is Disabled or Denied to access sql engine
User Action
If you are trying to connect using SQL Server Authentication, verify
that SQL Server is configured in Mixed Authentication Mode.
If you are trying to connect using SQL Server Authentication, verify
that SQL Server login exists and that you have spelled it properly.
If you are trying to connect using Windows Authentication, verify
that you are properly logged into the correct domain.
If your error indicates state 1, contact your SQL Server
administrator.
From this article
Should this not help try troubleshooting this issue following these steps.

SQL Server 2008 - Login failed for user 'user1' The user is not associated with a trusted SQL Server connection

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

Resources