The operating system returned error 5 access is denied while attempting



The operating system returned the error ‘5(Access is denied.)’ while attempting ‘RestoreContainer::ValidateTargetForCreation’

ERROR MESAGGE:

“System.Data.SqlClient.SqlError: The operating system returned the error ‘5(Access is denied.)’ while attempting ‘RestoreContainer::ValidateTargetForCreation’ on ‘C:\Program Files\Microsoft SQL Server\MSSQLx.MSSQLSERVER\MSSQL\xxx.mdf’. (Microsoft.SqlServer.Smo)”

EXPLANATION:

If you try to restore a backup file to a SQL Server Instance, you will see this error message if your SQL Server service does not have the required permissions to the folder that you want to restore the backup.

SOLUTION:

The SQL Server service performs the restoration of database backups. Restoring a backup file means that the SQL Server service will open your database files from the backup file to the destination folder. This means that your SQL Server service account must have write permissions in the destination folder where the database files will be created.

To do this, you must authorize the SQL Server service to write to the destination folder.

Author: Ekrem Önsoy

The original article was written in Turkish by Ekrem Önsoy and translated to English by dbtut with the consent of the author. The copyright of the article belongs to the author. The author shall not be liable in any way for any defect caused by translation.

Источник

The operating system returned error 5 access is denied while attempting

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Asked by:

Question

Here’s my sql. Any help is much appreciated.

All replies

Your error: error ‘5(Access is denied.)

Indicates the SQL Server service account does not have access to the file/directory. The restore does not run as the user running the command, but the service account user.

  • Edited by Tom Phillips Wednesday, September 18, 2019 12:36 PM
  • Proposed as answer by Lydia Zhang Microsoft contingent staff Thursday, September 19, 2019 9:40 AM

>>The operating system returned the error ‘5(Access is denied.)’ while attempting ‘RestoreContainer::ValidateTargetForCreation’ on ‘E:\DATABASES\ContinuingDB-data.mdf’

The reasons for the error may be the following:

  • The account that sql server is running under does not have access to the location where you are trying to restore the database to. Make sure service account have sufficient permission or try to use local system instead.
  • If the database is encrypted, you must have access to the certificate or asymmetric key used to encrypt the database. Without that certificate or asymmetric key, you cannot retore the database.

Источник

The operating system returned error 5 access is denied while attempting

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Asked by:

Question

Here’s my sql. Any help is much appreciated.

Читайте также:  Debug io socket ssl pm 1177 global error undefined ssl object

All replies

Your error: error ‘5(Access is denied.)

Indicates the SQL Server service account does not have access to the file/directory. The restore does not run as the user running the command, but the service account user.

  • Edited by Tom Phillips Wednesday, September 18, 2019 12:36 PM
  • Proposed as answer by Lydia Zhang Microsoft contingent staff Thursday, September 19, 2019 9:40 AM

>>The operating system returned the error ‘5(Access is denied.)’ while attempting ‘RestoreContainer::ValidateTargetForCreation’ on ‘E:\DATABASES\ContinuingDB-data.mdf’

The reasons for the error may be the following:

  • The account that sql server is running under does not have access to the location where you are trying to restore the database to. Make sure service account have sufficient permission or try to use local system instead.
  • If the database is encrypted, you must have access to the certificate or asymmetric key used to encrypt the database. Without that certificate or asymmetric key, you cannot retore the database.

Источник

The operating system returned error 5 access is denied while attempting

Question

Some background: I run a batch file to backup SQL databases running on a VM nightly. The batch file creates a .bak file for each database. This batch job has been running for nearly 12 years without fail. On 2/10 I discovered the error in Event Viewer. I then ran DBCC CHECKDB to find one of the databases corrupt. This error has never occurred prior nor has it popped up since and I am stumped as information on this error is minimal. I understand that the error references a permissions issue so I am hoping to get some help on what might be the cause.

Server 2012 R2
SQL 2012
Error Message: The operating system returned the error ‘5 (Access is Denied)’ while attempting create file «UNC path to directory» at ‘fileprod.ccp (1047)

Thanks in advance.

All replies

Yes the error point to a permission issue on the UNC path, maybe a security policy is bothering the process. Just make sure that the sql server agent service account has enough permission to access the resource.

hope this helps!

The information you uhave provided is minimal, and I can’t see the connection between the corruption and the permission error.

That error message does it really say «UNC path to directory»? Or did you replace the actual name with this string?

Читайте также:  Cpu fan error p9x79

What does your batch file look like?

The fact that has been running for 12 years is no guarantee for that it will not failing. Particularly, if it is writing a to file share, this will start failing the day someone removes the permission on the file share.

Corruption is typically due to malfunctioning hardware or drivers, and is nothing to take lightly. (Because as long as that hardware around, it is likely to keep on munching your data.)

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

You are correct. «UNC path to directory» in place of the actual path. I also agree that the connection between the corruption and the permission error is difficult to see. The event viewer clearly states the error:

The operating system returned the error ‘5 (Access is Denied)’ while attempting create file «UNC path to directory» at ‘fileprod.ccp (1047)

Of which I could find very little information on other than it is a permission issue.

The length of time this backup job has ran is only to show that if I had permission issues, I would assume the job would not run at all. This was a one time problem that to date, I cannot explain.

The batch file is a simple MssqlDatabaseBackup.exe job run each night. I have looked at all hardware, storage, power, drivers and firmware. pretty much everything I could and everything is up to date and running fine. I have looked at more log files than I can shake a stick at. I cannot find why this error occurred and this is the reason behind this post. I was hoping someone could direct me to something I may have missed.

I do appreciate your response and welcome any comments as I am at a loss.

Источник

The operating system returned error 5 access is denied while attempting

Question

Some background: I run a batch file to backup SQL databases running on a VM nightly. The batch file creates a .bak file for each database. This batch job has been running for nearly 12 years without fail. On 2/10 I discovered the error in Event Viewer. I then ran DBCC CHECKDB to find one of the databases corrupt. This error has never occurred prior nor has it popped up since and I am stumped as information on this error is minimal. I understand that the error references a permissions issue so I am hoping to get some help on what might be the cause.

Читайте также:  Reallocated sectors count error the

Server 2012 R2
SQL 2012
Error Message: The operating system returned the error ‘5 (Access is Denied)’ while attempting create file «UNC path to directory» at ‘fileprod.ccp (1047)

Thanks in advance.

All replies

Yes the error point to a permission issue on the UNC path, maybe a security policy is bothering the process. Just make sure that the sql server agent service account has enough permission to access the resource.

hope this helps!

The information you uhave provided is minimal, and I can’t see the connection between the corruption and the permission error.

That error message does it really say «UNC path to directory»? Or did you replace the actual name with this string?

What does your batch file look like?

The fact that has been running for 12 years is no guarantee for that it will not failing. Particularly, if it is writing a to file share, this will start failing the day someone removes the permission on the file share.

Corruption is typically due to malfunctioning hardware or drivers, and is nothing to take lightly. (Because as long as that hardware around, it is likely to keep on munching your data.)

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

You are correct. «UNC path to directory» in place of the actual path. I also agree that the connection between the corruption and the permission error is difficult to see. The event viewer clearly states the error:

The operating system returned the error ‘5 (Access is Denied)’ while attempting create file «UNC path to directory» at ‘fileprod.ccp (1047)

Of which I could find very little information on other than it is a permission issue.

The length of time this backup job has ran is only to show that if I had permission issues, I would assume the job would not run at all. This was a one time problem that to date, I cannot explain.

The batch file is a simple MssqlDatabaseBackup.exe job run each night. I have looked at all hardware, storage, power, drivers and firmware. pretty much everything I could and everything is up to date and running fine. I have looked at more log files than I can shake a stick at. I cannot find why this error occurred and this is the reason behind this post. I was hoping someone could direct me to something I may have missed.

I do appreciate your response and welcome any comments as I am at a loss.

Источник

Оцените статью
toolgir.ru
Adblock
detector