Software⏱️ 3 min read📅 2026-06-19

How to Fix error 5120 Error – SQL Server Express while attaching a database getting error 5120

SQL Server Express error 5120 fix for attaching database file

Quick Answer: Check SQL Server Express permissions and ensure the correct user account is used to attach the database.

The error 5120, 'Unable to open physical file', occurs when SQL Server Express is unable to access a database file due to insufficient permissions or file system issues. This issue affects users who attempt to attach a database file to their local instance of SQL Server Express.

This error can be frustrating as it prevents users from accessing their important data. However, by following the steps outlined in this guide, you should be able to resolve the issue and access your database files.

💡 Why You Are Getting This Error

  • The primary reason for this error is that SQL Server Express requires administrative privileges to attach a database file. If you are running SQL Server Express as a standard user account, you may not have the necessary permissions to access the database file.
  • Another possible cause of this error is if the file system where the database file is located has issues or is corrupted, resulting in an 'Access is denied' error.

🚀 How to Resolve This Issue

Granting Administrative Privileges

  1. Step 1: Open SQL Server Management Studio and connect to your local instance of SQL Server Express.
  2. Step 2: In the Object Explorer, right-click on the server and select 'Tasks' > 'Database Tasks' > 'Attach Database'.
  3. Step 3: Click on the 'Browse' button next to 'Database file' and navigate to the location of your database file (e.g., C: ile name.mdf).
  4. Step 4: If prompted for credentials, enter your administrative username and password.
  5. Step 5: Once you have granted yourself administrative privileges, try attaching the database file again.

Checking File System Permissions

  1. Step 1: Open File Explorer and navigate to the location of your database file (e.g., C: ile name.mdf).
  2. Step 2: Right-click on the database file and select 'Properties'.
  3. Step 3: In the Properties window, ensure that you have read and write permissions for the user account running SQL Server Express.
  4. Step 4: If you are using a shared folder or network location, verify that your user account has the necessary permissions to access the folder.

✨ Wrapping Up

By following these steps, you should be able to resolve the error 5120 and attach your database file to your local instance of SQL Server Express. Remember to always ensure that you have administrative privileges or correct file system permissions before attempting to attach a database file.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions