I have a new local sql server database, running hypothetically on port 48000. In SQL Server Management Studio under the name of the computer\MSSQLSERVER01, Security, Logins I clicked sa, properties and set the password. I have created a database, mystuff. sa is not listed under security under mystuff. I have the connection string jdbc:sqlserver://MYDESKTOP\MSSQLSERVER01:48000;databasename=mystuff;user=sa;password=123 but I get "Login failed for user 'sa'" when I attempt to connect. What else do I need to do to setup sa? Something under mystuff?
1 Answer
You should not be connecting any application to your database installation using the installation owner account ("sa"). Instead, create an account dedicated for the use of your Application and grant that account the right privileges.
Why?
Always keep the biggest and best tools in the box for yourself, because it's your job to clean up the "mess" made by everyone (and everything) else!
If an application connects with an "overpowered" account, like "sa"' and that application gets hacked, then your database can be wrecked in all sorts of nasty, painful and expensive to recover ways!
Save yourself the grief.
-
I understand what you are saying. this is on a development computer and I'm the only user– Chris94Commented Apr 26, 2021 at 21:52
-
in any case I still can't log in with jdbc and sa using my connect string and I would like to understand why– Chris94Commented Apr 26, 2021 at 21:53
-
I /think/ the default Authentication Mode for SQL Server only allows [the more secure] Windows Authentication, not the SQL Server Authentication that you're trying to use here. You'd have to reconfigure SQL Server into Mixed Mode to allow it. Not that you necessarily should. It may be better to have your client application use a "trusted" connection, so that it "passes through" the active, Windows user. Connecting from an Application using the "sa" account, even on a single-user, development machine is still a really Bad Idea.– Phill W.Commented Apr 27, 2021 at 10:03
sa
kind of owns everything and can do pretty much anything on a SQL Server instance, so you don't need to give it any privileges other than enable it to login (a basic test: can you login withsa
from management studio?