Home » How to fix database SQL server error 4060?

How to fix database SQL server error 4060?

sql server DBA 999

How do I resolve database error 4060 in SQL Server?

If you use a SQL database, you may encounter SQL Error 4060 following a database migration. This is one of the many SQL Errors that administrators must deal with. SQL Error 4060 occurs on the server. As a result, the client has little control over the situation. You require an immediate solution. We’ll show you how to fix SQL Error 4060 here.

Errors include

  1. sql server error 4060 cannot open database
  2. sql state 08004 sql server error 4060 or sql state 08004 error 4060
  3. fatal sql error 4060 occurred during company login
  4. unable to open the specified server database 4060
  5. error number 4060 state 1 class 11 or error number:4060,state:1,class:11
  6. server rejected the connection; access to selected database has been denied

Cause for SQL Server Error 4060

After migrating a website or application, users may encounter SQL Error 4060, which reads “Connection Failure: Server Rejected the Connection, Access to Selected Database Denied.” This error appears because:

  1. There were insufficient valid credentials to access the database, so access was denied
  2. Network Protocol was not enabled
  3. Access was blocked by a firewall

Solution for SQL Server 4060 Error

  1. No valid credentials supplied or credentials have no permission

The most serious problem with error 4060 in sql server is that the user did not have permission to view the database objects. They did not face this problem prior to migration because they had the necessary permission. As a result, after migration, you, as an administrator, should grant them permission.

You must use the Transact-SQL or TSQL command to grant the privileges. This command appears to be:

GRANT <permission> [] TO <database_principal> [] [ WITH GRANT OPTION] [AS <database_principal>  As you can see, the first line of code grants the required permission, and the second line to a specific user.

Similarly, you can grant permissions to other users based on their roles.

This should resolve the issue. If not, move on to the next solution.

All connections to the SQL Server Database Engine require a network protocol, which should be enabled. If not, the database will generate the 4060 error.

For example if you encounter below error

SQLDriverConnect: RETCODE=-1, State=37000, Native
Error=4060 [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open
database required.

Resolving the SQL 4060 above is to set database to “Single User” or permissions issue. To resolve these errors:

  1. SQL 4060 above can occur when database is in “Single User” access, so set it back to Multi user access. To remove single user mode in sql server is achieved with the ALTER DATABASE statement as follows:

  2.  Make sure no server roles are enabled for the application login in Server Roles but only database permissions list by application provider correctly like read, write, execute etc…

2. To resolve Network protocol error for sql server 4060, follow these steps:

  • Go to the programme’s list by clicking on “Start”
  • From the list, select “SQL Server Configuration Manager”
  • Then navigate into SQL Server Network Configuration and Protocols for machine instance>.
  • Double click on “Named Pipes”. This will open the Named Pipes Properties tab
  • Select “Yes” for the Enabled option and then OK to confirm.

Also like the above, you also need to enabled TCP/IP.

  • Go to the list of programs by click on Start and select “TCP/IP”.
  • From the properties screen, select “Yes” on the Enabled parameter.
  • Now go to the IP Addresses tab and select “Yes” for the IP address.
  • Also check for the correctness of TCP Port.
  • Finally click “OK

3.Firewall Blocking issue

If neither of the preceding solutions resolves the problem, it is more likely that a firewall is preventing access to the database. To fix this, simply instruct the firewall to grant the user access. Navigate to the firewalls that have been installed and look for permissions. If it hasn’t already been granted to the user, do so.

SQL Error 4060 can also be caused by other problems. A corresponding database, for example, may not have been properly copied into a new environment. There are also issues with rows and objects. Although these are uncommon, we recommend that you investigate them if the SQL 4060 error persists.

Leave a Reply

Your email address will not be published. Required fields are marked *