47

I am trying to connect to SQL Server 2008 using 'sa' username and its password. In the SQL Server log file I see this error:

Login failed for user 'sa'. Reason: An attempt to login using SQL authentication failed. Server is configured for Windows authentication only.

When I right-clicked on the server -> Properties -> Security "SQL Server and Windows authentication mode" is chosen.
I thought it's a problem with the 'sa' user so I did:

ALTER LOGIN sa ENABLE ;
GO
ALTER LOGIN sa WITH PASSWORD = '<enterStrongPasswordHere>' ;
GO

But it didn't help.
What else can it be?

user990635
  • 3,979
  • 13
  • 45
  • 66

7 Answers7

86

It looks like you will need to restart your SQL Server according to the MSDN link on enabling Mixed-Mode Authentication

There is another article (user comment at the bottom) referencing a registry key that you can look at; it also says you will need to restart the service once you have changed it.

From the first link:

To change security authentication mode:

  • In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.

  • On the Security page, under Server authentication, select the new server authentication mode, and then click OK.

  • In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.

To restart SQL Server from SQL Server Management Studio

  • In Object Explorer, right-click your server, and then click Restart. If SQL Server Agent is running, it must also be restarted.
Adam Wenger
  • 17,100
  • 6
  • 52
  • 63
21

You have to enable mixed mode server authentication:

enter image description here

Stephan
  • 4,187
  • 1
  • 21
  • 33
  • 7
    After this, do not forget to RESTART you SQL Server: In Object Explorer, right-click your server, and then click Restart. – Roman Nov 14 '14 at 10:21
2

After much research, I was able to connect my netbeans to my microsoft server.

If you registered your server as window authentication, you have to create another login which should be SQL Server Authentication, this will prompt you to input your username and password, create new, if you don't have any already existing login.

Map your new login to any database, preferably Master or Adventure...

Go to server manager configuration tool in your MSSQL folder in the start up menu,

Manager configuration tools ---> SQL Server services -----> select your server instance from the right pane, select MSSQLSERVER or MSSQLEXPRESS

whichever you know is your instance, preferably, work on the two of them, one after the other.

MSSQLSERVER express ---->under security----> Startup Parameters----> specify a parameter ---> type -m in the box ----> click on ADD.

CLick APPLY, then OK.

Do same to the MSSQLEXPRESS.

Restart the two of them Go back to your SQL management studio, Connect to server, select SQL SERVER AUTHENTICATION Input your username and password, then ok.

Open your netbeans, right click your database, do your new connection stuff with the JDBC driver, input your login details of the SQL server...... connect.

It works perfectly well.

Remember to enable your TCP/IP Port remains 1433

1

To resolve this issue, include TRUSTED_CONNECTION = TRUE in the connection string.

0

At first change password of user 'sa' and put some strong password then restart server and in place of server name use only 'ABC-PC' not like this 'ABC-PC\SQLEXPRESS' and then put user name 'sa' and and check Test Connection. I think it works. Thanks

0

Make sure The Port numbers for all instances are unique and the instance you are trying to access has port number specified in the code.

0

In case sql authentication is not working or not able to login follow the below steps to update your login password

1.Try logging in with Windows authentication. 2.In the left side database panel, select Security. 3.Under Logins, locate the login name you are trying to connect with. 4.Right-click on the login name and select Properties. 5.You should now be able to see the password field. Update the password as needed.

krickx
  • 31
  • 4