Unable to open the physical file [Database Name].mdf. Operating system error 5: “5(Access is denied.)”. (Microsoft SQL Server, Error: 5120)

It is ACL list error (access control list).

attachdb_access_denied

Possible reasons:

  • SQL Server service (sqlsrvr.exe) should have RW permissions on the folder that contains the .BAK file (check service account SQL engine is using)
  • Trying to create the MDF and LDF file for the intended database at a different location as compared to the default directories

Possible Solutions:

  • Add the service account running the SQL Server to have full RW access to the folder that contains the .BAK file using security permissions or
  • move the .BAK file (or MDF/LDF files depending on restore or attach option) to the default folder for SQL Server backups or
  • starts SSMS as administrator or
  • change the user account running the SQL service to an account who has admin privileges to the folder containing .BAK file, attach DB and then revert back with original account

Summary of solutions : SQL Server service account should have access to the folders where it is reading or writing to avoid ACL permissions issues.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>