AntonioCS
AntonioCS

Reputation: 8496

SQL Server 2005 backup restore failing (with folder permissions)

I am trying to restore a database (from file thedb.bak). I am using SQL Server Express edition 2005 on a Windows 7 Ultimate 64-bit machine.

When I try to restore I get the following error:

System.Data.SqlClient.SqlError: The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.2\MSSQL\Thedb.MDF'. (Microsoft.SqlServer.Express.Smo)

My username (antoniocs) is an Administrator. I have edited the permissions in the folder (C:\Program Files (x86)\Microsoft SQL Server\MSSQL.2\MSSQL\) so that the user AntonioCS has full control.

I really need to restore this backup. What am I missing?

Note: I am using the Windows authentication to login. Should I try another user (the one I use is an administrator in the machine)?

Upvotes: 0

Views: 2043

Answers (2)

CynicalSection
CynicalSection

Reputation: 704

Do you have a database that uses Thedb.MDF? I ran into this error when I tried to restore a database over a file that SQL Server used. From the restore window, choose Options and change the path or the filename from the "Restore the database files as".

Upvotes: 0

gbn
gbn

Reputation: 432311

The account running the SQL Server service requires permissions on that folder.

You may be connected to SQL Server, but actions are done in the service account context: not you.

Run services.msc from command line, see what account is used, permission this folder accordingly.

Upvotes: 2

Related Questions