Cannot open user default database. Login Failed (Microsoft SQL Server, Error: 4064)

I don’t know exactly what caused this, but today I tried to start SQL Server 2005 Management Studio, and got the following error: Cannot open user default database.  Login Failed (Microsoft SQL Server, Error: 4064)

4064 Error

  • When the “Connect to Server” dialog comes up, choose the Options>> button Connect to database dialog
  • Next to “Connect to database:” type in “master” rather than <Default>defaultmaster
  • Connect

It’s that simple.

If that does not completely solve the problem, then you’ll want to run SQL command from the command line, also very easy.

  • Open a command prompt (Windows Key + R and type cmd)
  • Type
    •  sqlcmd -E -d master
    • ALTER LOGIN [DomainName\UserName] WITH DEFAULT_DATABASE = master
    • GO
    • QUIT

cmd1.jpg

Refer to  this blog post for more information


About this entry