Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 561
2xMax Avatar asked Aug 16 '10 15:08

2xMax


People also ask

How do I fix OS error 5 access is denied?

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. Also, it may help to start SQL Server Management Studio as Admin, not just the server service.

What permissions are needed to restore a SQL Server database?

If the database being restored does not exist, the user must have CREATE DATABASE permissions to be able to successfully restore the database. If the database exists, RESTORE permissions default to members of the sysadmin and dbcreator fixed server roles and the owner ( dbo ) of the database.


1 Answers

I recently had this problem. The fix for me was to go to the Files page of the Restore Database dialog and check "Relocate all files to folder".

Restore Database dialog

like image 106
Jamie Humphries Avatar answered Oct 04 '22 09:10

Jamie Humphries