1

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.

2 Answers 2

2

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>. alt text

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'
Sign up to request clarification or add additional context in comments.

Comments

1

In SSMS: Server->Security->General Tab->Default Database

1 Comment

Thanks Mitch, I know this option but I can not login and I don't have access to the server from where I can login using Windows Authentication. Please see my edit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.