An error occurred while attaching the database to SQL Server. Error 5120 solution

Source: Internet
Author: User

An error message is returned when you attach a database to SQL Server.

Unable to open physical file XXX, OS error 5 (access denied), SQL Server error 5120

Solution 1 (verified ):

When logging on to sqlserver, you can use "windows Authentication" to log on to the database;

Solution 2 (unverified ):

Copy the mdf file from another host and attach it to the SQL server on the local machine. When attaching the mdf file, an error is Prompted. The file cannot be opened. Error 5102 is displayed because the permission is insufficient. Select the database file to attach, right-click Properties-Security-edit and grant the authenticated user full control permissions.

Solution 3:

Set the permissions for the folder where the mdf file is located (in some documents, only set the permissions for the mdf file, but I tried to use them), right-click the folder and choose Properties> Security, as shown in the figure.

Select Authenticated Users from the group or user name, click edit to modify permissions, select allow full control, and click OK.

Another solution is to check the information and do not log on with the sa account. If you log on with windows identity verification, you can append the information successfully. However, on the contrary, I cannot log on with windows identity verification, log on with the sa account and you will be able to attach it successfully. (Amazing ~~ I am very grateful if you know why I have trouble)

Supplement: when attaching a database to Sqlserver2005, an error occurs, indicating an operating system error. 5 (access denied). Error 5120. Solution:

 

Modify service
Select all programs-SQL Server 2005-Configuration tools-select "SQL Server Configuration Manager" or "SQL Server Configuration Manager ",
Open the "SQL Server Configuration Manager" Configuration interface, select "SQL Server 2005 service" on the left, right-click on the right to open the "SQL Server (SQLEXPRESS)" attribute, change the Network Service-"Network Service" in the built-in account to the Local System-"Local System ",
Click "restart" and then attach the database.
This method has been tested by myself.
 
If you are worried about changing the settings after attaching the database, you can use the "Local System" in the built-in account before changing it back.
"Network Service", the database can still be opened.
The main configuration process is as follows:
1. Open the "SQL Server Configuration Manager" Configuration page:
 
  
 
2. Select sq( SQLEXPRESS), and right-click:
 
  
 
3. Select "Local System ":
 
  
4. Select "restart ":
 
 
5. Configuration successful:
 
  
 
In this way, no errors will occur when you attach the database after the configuration.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.