简体   繁体   中英

Unable to open the physical file. Operating system error 5: "5(Access is denied.)"

I am trying to work on a query to attach a database (UNC path) remotely. I have SQL Server management studio (SSMS) installed in SQL Server machine (machineSQL) and also in another machine (machineRemote) in same domain.

Query::

CREATE DATABASE "simpleData" ON 
(FILENAME = '\\machineRemote\ShareName\sample\sample_database.mdf'),
(FILENAME = '\\machineRemote\ShareName\sample\sample_database_log.ldf')
FOR ATTACH;

If i run the query in SSMS on machineSQL. The database gets attached successfully. But if i run it in SSMS on machineRemote it throws an error like :

Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "\\machineRemote\ShareName\sample\sample_database.mdf". Operating system error 5: "5(Access is denied.)".
Msg 1802, Level 16, State 7, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

NOTE : The issue is occurring only if windows authentication is used to log in SSMS. SQL Server authentication works just fine.

Need help on this.

You have to allocate Full Control permission for the user to the mdf and ldf files. Check the screenshot below. 在此处输入图像描述

Hope it helps.

Reference: https://docs.microsoft.com/en-us/answers/questions/105605/unable-to-open-the-physical-file-operating-system.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM