Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Error 5120 - failed to attach .mdf file

While attaching my .mdf file on my SQL Server database I am getting below error message:

Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA' Operating system error 5: "5(Access denied.)".

Error Message I don't have my .ldf file of associated database. How can I attach my .mdf file without .ldf file? I am using SQL Server 2014.

like image 993
Jason Clark Avatar asked Dec 25 '15 05:12

Jason Clark


People also ask

What is Microsoft SQL Server used for?

Microsoft SQL Server is a relational database management system (RDBMS) that supports a wide variety of transaction processing, business intelligence and analytics applications in corporate IT environments.


1 Answers

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

like image 122
maneesh Avatar answered Sep 17 '22 11:09

maneesh