SQL Server Error 5120 - failed to attach .mdf file

That error is telling you that the account that is running the SQL Server service doesn't have permission to the mdf file. Fix the permissions and it should attach just fine.

Pro tip: pictures of text aren't as useful as the actual text. :)


Run SQL Server Management Studio as Administrator to attach the .MDF file. After that, no need to run SSMS as Administrator any more.


GO to the folder where you have stored MDF file. You can either do this to the entire folder or the MDF/LDF individually. Select file/folder-> Right click ->click on "Security". Then "Edit'. If you dont have OWNER RIGHTS listed Click ADD and search for it, click OK. enter image description here

And then give Full Control to user OWNER RIGHTS. enter image description here

permission for mdf file