How to Fix SQL Server Attach Database error 5120

Summary: SQL is a domain specific language which is used for stream processing and in designing and programming for managing data in the relational data stream management system (RDSMS). MS SQL Server database provides the feasibility to access many records with a single command and also by using SQL database it is very easy for the users to migrate data from MS Access, Sybase, Oracle to MS SQL Server. Sometimes, while accessing the database, users encounter errors which hampers their way of doing work. One such error is SQL Server Attach Database error 5120, it occurs due to when MS SQL Server database does not have the authorization to access LDF and MDF  files of a database. In this blog, we will discuss different manual methods and professional method using SQL Database Recovery tool to Fix SQL Server Attach Database error 5120.
Download Now Purchase Now

Causes of Microsoft SQL Server Error 5120

  • Not open and run SQL Server Management studio with admin right.
  • When the MDF file is not in appropriate location.
  • Maybe system server is not authorized to store the server files and when a user attempts to connect database files to server SQL server error occurs.
  • Not using Windows Authentication account, while using SQL Server database because of which error 5120 occurs.

How to fix Microsoft SQL Server Attach Database error 5120 manually:

First, you need to create two user account like SQLAdminOne and SQLAdminTwo in order to fix error 5120  and then follow the below mentioned procedure:

  • Create  a new database by following ways:

  • Check Test File permission for MDF and LDF files:

Find and browse the location of MDF and LDF files & right click on the file >> Properties >> Security.

  • SQLAdminOne Detaches Test Database: By right click on the Test database >> Tasks >> Detach
  • Now, again check test file permission for MDF and LDF files: Test database LDF and MDF files permissions have changed and full permission are allowed to SQLAdminOne.

  • SQLAdminTwo attempts to attach Test database: Whenever there is limited permission on the SQL server database files,  Microsoft SQL server error 5120 occurs.
  • Allow full permission on MDF & LDF files of Test Database: To do this, you need to follow these step:
  1. First, right-click on the Testdatabase file and select  Properties.
  2. Click on Security tab & after that click on Edit.
  3. Now, click on Add & enter the object name to select as NT Service\MSSQL$SQL2013.
  4. Immediately, after that click on Check Names & then click on OK.
  5. Give this account Full Control to the file and click on OK.

6.  Reattach the Test database: Now, in this way, SQLAdminTwo is able to attach the Test database

Another Technique to resolve SQL Server Attach Database Error 5120:

If above-mentioned ways do not work and you are still facing error 5120, then in such case there are only two options left to do you can either restore all data from SQL Backup or fix it with the SQL Database Recovery software.

Salient Features of the software:

  • Recover both database files MDF and NDF.
  • Compatible with all versions of MS SQL Server.
  • Supports Server ROW-compression as well as PAGE-compression.
  • Save recovered data in new SQL database or in SQL script form.

Conclusion

After knowing the causes, the user can avoid Microsoft SQL server error 5120. In some cases, it can be solved by adding permissions to a drive or by allocating database files to its original location. And, if things don’t work by manual ways then a user can opt for an alternative technique.

About The Author:

With more than five years of experience in email migration, Data Recovery, Email Backup, and File Management, I combine my years of experience with a strong interest in new technology. My professional journey is fueled by a genuine passion for navigating and mastering the latest advancements in these fields, ensuring that I stay ahead of the curve and bring innovative solutions to the table.

Related Post

© Copyrights 2017-2024 Database File Recovery. All Rights Reserved.