Recently I formatted my computer and installed fresh SQL Server in it. I installed the AdventureWorks database in my database. Once done, I wanted to run few test scripts on my database. Just like every DBA, I decided to take backup of my database – this way I can restore it back to attain an original database state. As soon as I ran the backup command I ended up with the following error. This error is due to a permissions issue on the local disk and user account which is running SQL Server. In this blog post we will talk about the operating system error.
Msg 3201, Level 16, State 1, Line 1
Cannot open backup device ‘C:\AdventureWorks.bak’. Operating system error 5(Access is denied.).
Fix/Resolution/Workaround:
I checked which user accounts my SQL Server services are running.
I gave full permission to that account to get rid of the error.
NOTE: This whole experience was done on the my personal machine and not on the production server. Please check with your network administrator for permission on production server.
Let me know if you have ever faced such error and if you have, how did you fix the error. Please leave a comment with your answer. I hope you find this blog post helpful.
Reference: Pinal Dave (https://blog.sqlauthority.com)
54 Comments. Leave new
Thanks Pinal..On installation the default login was set so that i can’t access to my other drives..on change the accout to network services i get the access privilege for my windows account..
Can’t you change permission on the drive?
Thank you!
Your welcome spideynok! Thanks for taking time to let me know.
I too had this issue and got it resolved by using the above solution , but i would like to know how did i loose cerdentials all of a sudden on my xp machine for Log On user NETWORK SERVICE
Copy backup file to SQL 2012 backup folder works for me. Thanks.
it did not work for me, still getting this error
capture Process Monitor https://docs.microsoft.com/en-us/sysinternals/downloads/procmon and check the account which is getting access denied.
Procmon was handy to identify the account that needs access. Thanks Pinal Dave !
it opens for me, thanks
Thank you very much ,this article was very helpful :)
Thanks Aditya .
Hey,
Thanks a lot for your post. This method worked for me!
Thanks Sai
This information you provided is helpful, thank you very much
Thank you. This really worked for me.
Thanks, you save my life.
Where do you check “I checked which user accounts my SQL Server services are running.”
The solution you suggest would work absolutely fine for me. The first rule of thumb is we need to know the basic fundamentals which is — Any backup run under the service account, the service account must have full permission on backup folder.
Nope. That doesn’t work. I’ve done this for the SQL Server program folder, db folder, backup folder, tempdb folder and pretty much every possible folder SQL is running on (SQL 2017), no joy. Same error. There must be a bug in Windows (2012R2) that presented itself after updating from (2008R2). The only solution I can think of is to give “God Mode” access to “Everyone”, but that’s a really really bad idea. It would be nice to find a real, tangible, working solution to this problem (650,000+ inquiries on Google – this is an MS problem!)
After spending 2 days on everything under the sun, I found out that the problem is NOT with SQL at all, nor security on any of the SQL folders. The issue is with the TEMP folder of the user running the app.
C:\Users\Administrator\AppData\Local\Temp
To fix, grant Everyone read/write permission to the Temp folder for the user account(s) affected. This solves many issues for MS applications that use MSSQL (any flavor)
Does this need RDP access on target server where the folder is present.