SPNote

SharePoint Notes

Attaching a Database where locates in a specific directory

I was trying to attach a SQL Database into local SQL Express and got an error “Unable to open the physical file. Operating system error 5. 5(Access is denied)”.  The reason is for the lack of permissions. The default data directory has Full control permission to MSSQL$SQLEXPRESS. If you want to attach a database in a different location then you should add the permission to that directory.

Error

  • Error occurred when attaching a database
    clip_image0019

    Unable to open physical file - Operating system error 5: 5(error not found) Microsoft SQL Server: Error 5120
    clip_image0029

 

Test environment

  • SQL Server version: 2014 Express
    image
  • Data Path(Default): C:\Program Files (x86)\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA
  • Permission
    image
  • Service
    clip_image0048

    clip_image0067

Solution

  • Add Full control to MSSQL$SQLEXPRESS to the specific directory
    clip_image0078