SQL Server Operating system error 5: "5(Access is denied.)"
SQL Server database engine service account must have permissions to read/write in the new folder.
Check out this
To fix, I did the following:
Added the Administrators Group to the file security permissions with full control for the Data file (S:) and the Log File (T:).
Attached the database and it works fine.
An old post, but here is a step by step that worked for SQL Server 2014 running under windows 7:
- Control Panel ->
- System and Security ->
- Administrative Tools ->
- Services ->
- Double Click SQL Server (SQLEXPRESS) -> right click, Properties
- Select Log On Tab
- Select "Local System Account" (the default was some obtuse Windows System account)
- -> OK
- right click, Stop
- right click, Start
Voilá !
I think setting the logon account may have been an option in the installation, but if so it was not the default, and was easy to miss if you were not already aware of this issue.
To get around the access denied issue, I started SSMS as administrator and that allowed me to attach a database from my local drive. The database was created in another SQL and windows instance.