mssql ‘5 (Access is denied.)’ error during restoring database

I want to restore a database from a file (Tasks ? Restore ? Database; after I select from device and select file) via SQL Server Management Studio.

After that, I get this error:

The operating system returned the error ‘5(Access is denied.)’ while attempting
‘RestoreContainer::ValidateTargetForCreation’ on ‘E:\Program Files\Microsoft SQL
Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\XXXXXX.mdf’.
Msg 3156, Level 16, State 8, Server XXXX, Line 2

How do I fix this problem? Is it a security error?


Answer

The account that sql server is running under does not have access to the location where you have the backup file or are trying to restore the database to. You can use SQL Server Configuration Manager to find which account is used to run the SQL Server instance, and then make sure that account has full control over the .BAK file and the folder where the MDF will be restored to.

enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *