You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/relational-databases/errors-events/mssqlserver-5120-database-engine-error.md
+22-19Lines changed: 22 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,20 +27,22 @@ ms.author: mathoma
27
27
|Message Text|Table error: Unable to open the physical file "%.*ls". Operating system error %d: "%ls".|
28
28
29
29
## 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).
31
31
32
-
## User Action
32
+
## User action
33
33
34
34
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.
35
35
36
-
### Access is Denied
36
+
### Access is denied
37
37
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.
39
39
- 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.
41
41
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
44
46
Event Class: File System
45
47
Operation: CreateFile
46
48
Result: ACCESS DENIED
@@ -53,28 +55,29 @@ If you are getting the ```Access is Denied``` operating system error = 5, consid
53
55
Attributes: N
54
56
ShareMode: Read
55
57
AllocationSize: n/a
56
-
Impersonating: DomainName\UserName```
58
+
Impersonating: DomainName\UserName
59
+
```
57
60
58
61
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.
61
64
62
65
```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.).```
63
66
64
67
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.
65
68
66
69
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).
68
71
69
72
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
+
```
74
77
75
78
3. Use the following command to reattach the database.
0 commit comments