Skip to content

Commit 2412cf5

Browse files
authored
Merge pull request #15032 from MicrosoftDocs/Kellylorenebaker-patch-1-1
Edit pass: mssqlserver-5120-database-engine-error
2 parents 6937fdd + e8f0dc5 commit 2412cf5

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

docs/relational-databases/errors-events/mssqlserver-5120-database-engine-error.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@ ms.author: mathoma
2727
|Message Text|Table error: Unable to open the physical file "%.*ls". Operating system error %d: "%ls".|
2828

2929
## Explanation
30-
[!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] was unable to open a database file. The operating system error provided in the message points to more specific underlying reasons for the failure. You may commonly see this error together with other errors like [17204](mssqlserver-17204-database-engine-error.md) or [17207](mssqlserver-17207-database-engine-error.md)
30+
[!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] was unable to open a database file. The operating system error provided in the message points to more specific underlying reasons for the failure. You may commonly see this error together with other errors like [17204](mssqlserver-17204-database-engine-error.md) or [17207](mssqlserver-17207-database-engine-error.md).
3131

32-
## User Action
32+
## User action
3333

3434
Diagnose and correct the operating system error, then retry the operation. There are multiple states that can help Microsoft narrow down the area in the product where the area is occurring.
3535

36-
### Access is Denied
36+
### Access is denied
3737
If you are getting the ```Access is Denied``` operating system error = 5, consider these methods:
38-
- Check the permissions that are set of the file by looking at the properties of the file in Windows Explorer. [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] uses Windows groups to provision Access Control on the various file resources. Make sure the appropriate group [with names like SQLServerMSSQLUser$ComputerName$MSSQLSERVER or SQLServerMSSQLUser$ComputerName$InstanceName] has the required permissions on the database file that is mentioned in the error message. Review [Configure File System Permissions for Database Engine Access](../../2014/database-engine/configure-windows/configure-file-system-permissions-for-database-engine-access.md) for more details. Ensure that the Windows group actually includes the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service startup account or the service SID.
38+
- Check the permissions that are set of the file by looking at the properties of the file in Windows Explorer. [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] uses Windows groups to provision Access Control on the various file resources. Make sure the appropriate group [with names like SQLServerMSSQLUser$ComputerName$MSSQLSERVER or SQLServerMSSQLUser$ComputerName$InstanceName] has the required permissions on the database file that is mentioned in the error message. Review [Configure File System Permissions for Database Engine Access](../../2014/database-engine/configure-windows/configure-file-system-permissions-for-database-engine-access.md) for more details. Ensure that the Windows group actually includes the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service startup account or the service SID.
3939
- Review the user account under which the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service is currently running. You can use the Windows Task Manager to get this information. Look for the "User Name" value for the executable "sqlservr.exe". Also if you recently changed the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service account, know that the supported way to do this operation is to use the [SQL Server Configuration Manager](../sql-server-configuration-manager.md) utility.
40-
- Depending on the type of operation - opening databases during server startup, attaching a database, database restore, etc. - the account that is used for impersonation and accessing the database file may vary. Review the topic [Securing Data and Log Files](https://docs.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms189128(v=sql.105)?redirectedfrom=MSDN) to understand which operation sets what permission and to which accounts. Use a tool like Windows SysInternals [Process Monitor](https://docs.microsoft.com/sysinternals/downloads/procmon) to understand if the file access is happening under the security context of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] instance service startup account [or Service SID] or an impersonated account.
40+
- Depending on the type of operation (opening databases during server startup, attaching a database, database restore, and so on), the account that is used for impersonation and accessing the database file may vary. Review the topic [Securing Data and Log Files](https://docs.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms189128(v=sql.105)?redirectedfrom=MSDN) to understand which operation sets what permission and to which accounts. Use a tool like Windows SysInternals [Process Monitor](https://docs.microsoft.com/sysinternals/downloads/procmon) to understand if the file access is happening under the security context of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] instance service startup account [or Service SID] or an impersonated account.
4141

42-
If [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is impersonating the user credentials of the login that executes the ALTER DATABASE or CREATE DATABASE operation, you will notice the following information in the Process Monitor tool (an example):
43-
```Date & Time: 3/27/2010 8:26:08 PM
42+
If [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] is impersonating the user credentials of the login that executes the ALTER DATABASE or CREATE DATABASE operation, you will notice the following information in the Process Monitor tool (an example).
43+
44+
```
45+
Date & Time: 3/27/2010 8:26:08 PM
4446
Event Class: File System
4547
Operation: CreateFile
4648
Result: ACCESS DENIED
@@ -53,28 +55,29 @@ If you are getting the ```Access is Denied``` operating system error = 5, consid
5355
Attributes: N
5456
ShareMode: Read
5557
AllocationSize: n/a
56-
Impersonating: DomainName\UserName```
58+
Impersonating: DomainName\UserName
59+
```
5760
5861
59-
### Attaching Files that Reside on a Network-attached storage
60-
If you cannot re-attach a database that resides on network-attached storage, a message like this may be logged in the Application log:
62+
### Attaching files that reside on a network-attached storage
63+
If you cannot re-attach a database that resides on network-attached storage, a message like this may be logged in the Application log.
6164
6265
```Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file "\\servername\sharename\filename.mdf". Operating system error 5: (Access is denied.).```
6366
6467
This problem occurs because [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] resets the file permissions when the database is detached. When you try to reattach the database, a failure occurs because of limited share permissions.
6568
6669
To resolve, follow these steps:
67-
1. Use the -T startup option to start [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. Use this startup option to turn on trace flag 1802 in [SQL Server Configuration Manager](../sql-server-configuration-manager.md) (see [Trace Flags](../../t-sql/database-console-commands/dbcc-traceon-transact-sql.md) for information on 1802). For more information about how to change the startup parameters, see [Database Engine Service Startup Options](../../database-engine/configure-windows/database-engine-service-startup-options.md)
70+
1. Use the -T startup option to start [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. Use this startup option to turn on trace flag 1802 in [SQL Server Configuration Manager](../sql-server-configuration-manager.md) (see [Trace Flags](../../t-sql/database-console-commands/dbcc-traceon-transact-sql.md) for information on 1802). For more information about how to change the startup parameters, see [Database Engine Service Startup Options](../../database-engine/configure-windows/database-engine-service-startup-options.md).
6871
6972
2. Use the following command to detach the database.
70-
```tsql
71-
exec sp_detach_db DatabaseName
72-
go
73-
```
73+
```tsql
74+
exec sp_detach_db DatabaseName
75+
go
76+
```
7477

7578
3. Use the following command to reattach the database.
76-
```tsql
77-
exec sp_attach_db DatabaseName, '\\Network-attached storage_Path\DatabaseMDFFile.mdf', '\\Network-attached storage_Path\DatabaseLDFFile.ldf'
78-
go
79-
```
79+
```tsql
80+
exec sp_attach_db DatabaseName, '\\Network-attached storage_Path\DatabaseMDFFile.mdf', '\\Network-attached storage_Path\DatabaseLDFFile.ldf'
81+
go
82+
```
8083

0 commit comments

Comments
 (0)