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

  • Hi All,

    I am trying to attach a database. But I am receiving below error:

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

    I have added service accounts to administrator group.

    I have provided full control to service account on the D drive and on the .mdf file also.

    My self has full permissions on the drive and .mdf file, and I am in administrator group.

    Restarted the SQL Server services.

    Still same error.

    Could you please help me in this issue.

    Thank You.

    Regards,

    Raghavender Chavva

    Thank You.

    Regards,
    Raghavender Chavva

  • Raghavender (11/6/2015)


    Hi All,

    I am trying to attach a database. But I am receiving below error:

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

    I have added service accounts to administrator group.

    I have provided full control to service account on the D drive and on the .mdf file also.

    My self has full permissions on the drive and .mdf file, and I am in administrator group.

    Restarted the SQL Server services.

    Still same error.

    Could you please help me in this issue.

    Thank You.

    Regards,

    Raghavender Chavva

    Quick thought, create a folder in the root of the drive and set the ownership of the folder to the sql server service credentials

    😎

  • Raghavender (11/6/2015)


    Hi All,

    I am trying to attach a database. But I am receiving below error:

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

    I have added service accounts to administrator group.

    I have provided full control to service account on the D drive and on the .mdf file also.

    My self has full permissions on the drive and .mdf file, and I am in administrator group.

    Restarted the SQL Server services.

    Still same error.

    Could you please help me in this issue.

    Thank You.

    Regards,

    Raghavender Chavva

    put the file into a subfolder and grant the relevant NTFS permissions, this is the only supported and correct way to provide user access to the files

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Still no use. Receiving the same error.

    Thank You.

    Regards,
    Raghavender Chavva

  • You sure you are selecting the correct file?

  • Ratheesh.K.Nair (11/9/2015)


    You sure you are selecting the correct file?

    Yes Ratheesh..

    Thank You.

    Regards,
    Raghavender Chavva

  • Can you see Lock Icon on those files?

  • I could not see any locks on those files.

    Thank You.

    Regards,
    Raghavender Chavva

  • Any other instance running on that server?

    The file be held by some other process. Hope you have already tried keeping the file in other sub-directory or another drives.

  • Only one instance is running and we have made separate directory for that file.

    We tried by moving the mdf and ldf files to different drives.

    But no luck.

    Thank You.

    Regards,
    Raghavender Chavva

  • have you set the necessary permissions to the folders?

  • Are you able to connect to instance without any issue??

    Try running SSMS as administrator. Also check what error you get while using query sp_attach_db.

  • Ratheesh.K.Nair (11/9/2015)


    Are you able to connect to instance without any issue??

    Try running SSMS as administrator. Also check what error you get while using query sp_attach_db.

    Yes, able to connect the instance without any issues.

    Also tried by Running SSMS as administrator. No Luck.

    I have tried all the possible options I can, but no use. Not sure where the blocking is.

    have you set the necessary permissions to the folders?

    Anthony,

    We have full control on those folders and files.

    We are added in admin group on that box.

    Thank You.

    Regards,
    Raghavender Chavva

  • Its not you / the admin that needs rights its the service account running SQL.

    You can have all the rights you want/need, if SQL can't access the file you can't get the file into SQL

  • anthony.green (11/9/2015)


    Its not you / the admin that needs rights its the service account running SQL.

    You can have all the rights you want/need, if SQL can't access the file you can't get the file into SQL

    Yes Even service accounts are added into admin group and we have given full control on the folder and files.

    Thank You.

    Regards,
    Raghavender Chavva

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic. Login to reply