Easy Hacks to Fix SQL Server 4064 Error : Login Failed Issue

  • Written By  

  • Published on July 31st, 2020

  • Updated on November 1, 2021

5/5 - (1 vote)

Summary: Many users fail to log in to their Microsoft SQL server. This may be due to the Microsoft SQL server 4064 error – “Cannot open user default database login failed”. Errors are unavoidable as this can break the workflow of any company. So, if you are getting the same error then you land on the right page. Today in this blog we’ll get to know the process to fix error 4064.

Error Message: Cannot open user default database. Login failed.

 SQL Error 4064

Each error of the SQL server is identified by a number and the error message mentioned above occurs when a user tries to connect to an instance of SQL Server. The message is identified as SQL error 4064.

Why SQL Error 4064 Login failed Occur?

error 4064

  • Every user that holds an account on any concern server has a database by default.
  • And when they try to connect with SQL Server without specifying a login database, the default database is utilized.
  • But you can get an error or connection may fail if the default database is unavailable when you try to link. Hence, they will get an error like 4062 or 4064 is received.
  • That is not only the reason to get an error, but there may also be a lot more reasons for this error like the unavailability of the default database at the time of connection when they try to connect.
  • And this may be due to the database which stores information is in suspect mode or offline.

Hence, there may be many possibilities that it has been set to RESTRICTED_USER state or has been left detached. Some other reasons that can probably cause this error are:

  • No more existence.
  • Set for urgent situation status.
  • Exists in single-user mode and you are trying to connect with an account other than your main account.
  • If a user doesn’t have an account login that is mapped to a user.
  • The user has been deprived of access.
  • And is a part of the database mirror.

So, now we have discussed the reasons by which you probably get an error as the server login failed. Now we’ll get to know about the process to fix this SQL server error 4064 login failed error. There may be chances that you may face SQL Database Error 8921 sometimes.

How To Fix SQL Server 4064 Error?

If you want to fix error “Cannot open user default database login failed” follow these different methods that will help you to fix error on the different server environment, to fix the users’ database that is available for a connection.

For SQL version 2000 and 7.0 – OSQL utility can be used to change the default database. If you want to recover using the OSQL utility, follow the below commands..

  • In the command prompt window, type ‘C :\> osql -E -d master’ and press Enter key.
  • Open OSQL prompt and “type ‘1>sp_defaultdb ‘user’s_login’, ‘master” and click on Enter button.
    Type “2>go”, then press Enter button, a second prompt.

In SQL Server 2005 and for the version after 2005, use – SQLCMD utility to change default database. Following are the steps for the process:

Step1 – Open Command Prompt.
Step2 – As per Windows and SQL server authentication there are two different commands, choose accordingly:

  • Type command “sqlcmd –E -S InstanceName –d master” at the command prompt and then press Enter key if Windows authentication is used to connect to the instance.
  • Type command “sqlcmd -S InstanceName -d master -U SQLLogin -P Password” and then Enter, if your SQL Server authentication is used to connect to the instance.

Step3 – Type the following command in sqlcmd prompt in “ALTER LOGIN SQLLogin WITH DEFAULT_DATABASE = AvailDBName” and then press Enter.
Step4 – Then at ‘sqlcmd prompt’, type GO and press Enter.

Professional Method to Fix SQL Server Error 4064 login failed error 4064:

You can take the help of professional third-party tools to fix Microsoft SQL Server login failed error 4046. With the help of SQL Database Recovery Tool, users can recover both MDF and NDF files in SQL server. Also, this utility is a one-stop solution to recover all versions of MS SQL servers like 2000, 2005, 2008, 2012, 2014, and 2016. Try utility, if you want to make the repairing process faster and easier.

Final Words

In this blog, we have covered the reasons and the process to fix the Microsoft SQL Server 4064 Error Login Failed. But it is seen that users generally find these methods quite lengthy to follow. So, to make that process very simple and secure you will take the help of third-party tools to fix this issue.

About The Author:

Rohit Singh is an Email Backup, Recovery & Migration Consultant and is associated with Software Company from the last 3 years. He writes technical updates and their features related to MS Outlook, Exchange Server, Office 365, and many other Email Clients & Servers.

Related Post

100% safe and secure100% Safe & SECURE
SupportLifetime Support (24X7)
Money BackMoney Back Policy
Trusted by CustomersTrusted by 10000+ Customers