I have deleted my default db now I can not login using sql server authentication. How can I change default db back to Master db
EDIT:
I cannot login using sql server authentication. It gives me error
Cannot open user default database.
Login failed. Login failed for user
'xyz'. (Microsoft SQL Server, Error:
4064)
Thanks.
Connect via SSMS. In the connection dialog box, click on the "Options >>" button and change the "Connect to database:" option to be Master instead of <default>.
This should get you in. Then you can use the command below to change your login's default DB.
Exec sp_defaultdb #loginame='login', #defdb='master'
In SSMS: Server->Security->General Tab->Default Database
Related
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
Using SQL Server 2016 (localdb)\ProjectsV13, I created a database - let's call it MyDatabase. All was fine and dandy until I decided I no longer needed it...
So in SSMS 2016, while connected to (localdb)\ProjectsV13, I right clicked on MyDatabase and clicked "Delete".
Now when I try to establish a connection to (localdb)\ProjectsV13, it fails.
Here's the error message:
Cannot connect to (localdb)\ProjectsV13.
Cannot open database "MyDatabase" requested by the login. The login failed. Login failed for user 'MyDomain\MyUserName'. (Microsoft SQL Server, Error: 4060)
So even though I deleted the MyDatabase database (I know - I should of just run a DROP), SSMS is still trying to connect to MyDatabase which of course fails and then prevents me from connecting to (localdb)\ProjectsV13 at all - which is the real issue.
How can I resolve this so that SSMS doesn't try to connect to the deleted MyDatabase database when connecting to (localdb)\ProjectsV13?
Like Sean suggested, I think your default database is the problem. If you're using visual studio, right-click the server and click on the properties option. You'd see a 'Default Database Location' property. Alter the value.
If you're not using visual studio, then change your default database or check that your connection string does not attach the deleted database when you connect. E.g.
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\StaffLoginSystem.mdf;Integrated Security=True;Connect Timeout=30"
Check the value of 'AttachDbFilename' property and edit accordingly.
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)
When I try to connect to SQL Server 2005 Enterprise edition on my local machine I get the below error:
"Cannot open user dafault database.Login failed.
Login Failed for user "Domain\My name"
What can cause this error?
From SQl Server management studio try this
click the options button .
click the connection properties.
click on the Connect to database
type in the name of a database "master"
click connect.
Bye
Either the login's default database no longer exists, or the login has no rights to it. What version of SQL Server?
Another reason can be because SQL Server is failing to contact the domain controller.
If it can contact the domain controller then Kerberos could be failing due to a skewed system clock or active directory not containing service principle names for the server.
You can check for Kerberos authentication errors in the system's event log.