Cannot open user default database. Login failed. Microsoft SQL Server, Error:4064[Solved]

Yesterday When I was trying to connect to Microsoft SQL Server database, I got an error like this – Cannot open user default database. Login failed. Login failed for user. (Microsoft SQL Server,error:4064). I did not made any changes in configuration or settings of SQL server, but still was not able to open SQL server databases due to this error. This error shows up due to some deleted database which was mapped as default database to my username. When you try to access that default database, the SQL server does not able find that database.

Cannot open user default database. Login failed.

The solution of this problem is very simple. You need to set master as your default database. Here is how to do it:

Cannot open user default database. Login failed. – Fix

  • Click on the Options button in the Connect to Server window.

Microsoft SQL Server,error4064

  • Under the Connection Properties tab, Change the Connect to database value from <default> to master.

cannot open user default database. login failed sql 2014

Cannot open user default database. Login failed. Microsoft SQL Server,error4064[Solved]

  • Click on the Connect button and now you should be able to successfully log in.
  • After log in, you need to perform one more step to get rid of this error permanently. Type the following statement and hit F5 to run. Make sure to replace test with your Username and master with your database name(that you want to set as new default).
ALTER LOGIN [test] WITH DEFAULT_DATABASE = master

If you have made the above two replacements correctly, you should see a message – Command completed successfully.

alter login [test] with default_database = master

Whether this solution worked for you or not, let me know in comment section.

Recent Articles

Related Stories

1 Comment

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox