Skip to content

Latest commit

 

History

History
80 lines (65 loc) · 5.82 KB

mssqlserver-5120-database-engine-error.md

File metadata and controls

80 lines (65 loc) · 5.82 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords
MSSQLSERVER_5120
MSSQLSERVER_5120
pijocoder
jopilov
07/25/2020
sql
supportability
reference
5120 (Database Engine error)

MSSQLSERVER_5120

[!INCLUDE SQL Server]

Details

Attribute Value
Product Name SQL Server
Event ID 5120
Event Source MSSQLSERVER
Component SQLEngine
Symbolic Name DSK_FCB_FAILURE
Message Text Table error: Unable to open the physical file "%.*ls". Operating system error %d: "%ls".

Explanation

[!INCLUDEssNoVersion] 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 or 17207.

User action

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.

Access is denied

If you are getting the Access is Denied operating system error = 5, consider these methods:

  • Check the permissions that are set of the file by looking at the properties of the file in Windows Explorer. [!INCLUDEssNoVersion] 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 for more details. Ensure that the Windows group actually includes the [!INCLUDEssNoVersion] service startup account or the service SID.

  • Review the user account under which the [!INCLUDEssNoVersion] 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 [!INCLUDEssNoVersion] service account, know that the supported way to do this operation is to use the SQL Server Configuration Manager utility.

  • 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 to understand which operation sets what permission and to which accounts. Use a tool like Windows SysInternals Process Monitor to understand if the file access is happening under the security context of the [!INCLUDEssNoVersion] instance service startup account [or Service SID] or an impersonated account.

    If [!INCLUDEssNoVersion] 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).

    Date & Time:      3/27/2010 8:26:08 PM
    Event Class:        File System
    Operation:          CreateFile
    Result:                ACCESS DENIED
    Path:                  C:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\DATA\attach_test.mdf
    TID:                   4288
    Duration:             0.0000366
    Desired Access:Generic Read/Write
    Disposition:        Open
    Options:            Synchronous IO Non-Alert, Non-Directory File, Open No Recall
    Attributes:          N
    ShareMode:       Read
    AllocationSize:   n/a
    Impersonating: DomainName\UserName
    

Attaching files that reside on a network-attached storage

If you cannot re-attach a database that resides on network-attached storage, a message like this may be logged in the Application log.

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.).

This problem occurs because [!INCLUDEssNoVersion] resets the file permissions when the database is detached. When you try to reattach the database, a failure occurs because of limited share permissions.

To resolve, follow these steps:

  1. Use the -T startup option to start [!INCLUDEssNoVersion]. Use this startup option to turn on trace flag 1802 in SQL Server Configuration Manager (see Trace Flags for information on 1802). For more information about how to change the startup parameters, see Database Engine Service Startup Options.

  2. Use the following command to detach the database.

     exec sp_detach_db DatabaseName
     go 
  3. Use the following command to reattach the database.

    exec sp_attach_db DatabaseName, '\\Network-attached storage_Path\DatabaseMDFFile.mdf', '\\Network-attached storage_Path\DatabaseLDFFile.ldf'
    go