SQL Server error 5120: unable to open the physical file
Resolved SQL
JI
Jenna Ibrahim
November 3, 2026
2 replies
1,161 views
Reviewed by moderators
2 participants

I copied an MDF and LDF file to a new server and Attach fails with error 5120, operating system error 5, access denied. I am an admin on the box. Why?

Accepted answer
Marked as the solution to this question

Being an admin on Windows does not matter. The SQL Server service account needs permission on the files.

1. Find the service account in SQL Server Configuration Manager. It may be NT Service\MSSQLSERVER or a named account.
2. Right click the MDF and LDF files (or their folder), open Security, and give that account Full control or Modify.
3. Make sure the files are not read-only, and not open in another process.
4. Attach again.

Also check that you are attaching from a folder that the account can read. Files in your Downloads or Desktop folder are often blocked. Putting them in the SQL Server data folder is the easiest.

Gave the service account permission on the folder and the attach worked. Thanks.