I have Sql Server 2017 and the Data folder is the default at C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL. The access rights on the folder are:

I have an old database with its MDF file in My SQL Database. I tried to duplicate the same rights to My SQL Database:

I couldn't duplicate those for ALL APPLICATION PACKAGES as I don't know who it is.
With the above rights on My SQL Database I couldn't reattach a database from its MDF file in that folder. It keeps saying Operating system error 5: "5(Access is denied.)" on the MDF file.
What access permissions are required to have database files in another folder other than the default?
Execute the following SELECT:
SELECT * FROM sys.dm_server_services
And check the value of service_account for the servicename thats SQL SERVER:

Then make sure that the folder and the files have the proper access rights for that account.
Add your user account in Advanced Security Setting of the Data folder with Full Control access

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With