"Sql server error 5120" while attaching database

  • HI,

    I am trying to attach few databases to sql server 2005.I have my .mdf files in "D:\MSSQL\Data" and my .ldf files in "E:\SQLLogs".

    when i try to attach it gives me below mentioned error

    ------------------------------

    Unable to open the physical file "D:\MSSQL\Data\dbAcquisitionStaging_Data1.mdf". Operating system error 5: "5(Access is denied.)". (Microsoft SQL Server, Error: 5120)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476

    ---------------------------

    I am added as administrator to this server. I checked for permissions on the .mdf and .ldf files It says full control.

    Could anybody please advise on how to fix this issue.This is hindering my progress. Any kind of help will be greatly appreciated.

    Thanks in advance

    lays

  • need to check permissions to the actual file directories if all good then have your admin reset them, this has more to do with permissions with the directory you are trying to read and write.

  • Check the account under which SQL Server is running. That's the account that needs to have permissions to the files.


    And then again, I might be wrong ...
    David Webb

  • Thanks for the response.

    The problem is fixed. as the .mdf and .ldf files where on different drives

    it was giving some wierd error so i attached only mdf files and the server created .ldf files on the same drive as mdf. this way i could attach it but then i took the db offline copied the log from D:\ to E:\ and then brought the db online. it worked.

    thanks a ton for the responses.

  • Hello !!!

    try login with Windows Authentication.

    Gala;)

  • Hi Lays,

    How did u copy the log from D:\ to E:\ as mentioned.

    this way i could attach it but then i took the db offline copied the log from D:\ to E:\ and then brought the db online. it worked.

    Pls tell me how did u do this.

    Thanks in advance.

  • Although it's an old post, this problem is still actual. As this post wasn't closed with a working solution, I write it here:

    Start SQL Server manager as Administrator (right-click on the program, choose "Start as administrator"): problem solved!

    I wrote this solution on Developer's Challenges, SQL Server Error 5120 .

  • You are some amazing!

    Yes, it works perfectly.

    Thanks a lot ๐Ÿ˜€

  • If you are using windows 7. Open the studio management by Right click and

    Run as Administrator. then log on in windows mode and try to attach the database . It will work for sure :w00t:

  • dotnet-786228 (6/18/2008)


    Hello !!!

    try login with Windows Authentication.

    Gala;)

    Yaaaaaaaaaaa, this solution work fine ๐Ÿ˜€

    Viet Anh,

    cheers

  • Thank You Very Much:-)

  • THANK YOU!!!!!!!!!!!!! You saved me from more hours of frustration ๐Ÿ™‚

  • Hello Mr.

    รจ an old post, but decided that situation as follows:

    When you attach the base within the D: \ <folder> \ MSSQL \ Data presented this error so I created another folder inside the Data folder put the base you want to attach inside the folder I created and it worked then the path was D: \ <folder > \ MSSQL \ Data \ <new <folder

    Note: We attach multiple database within the directory D: \ <folder> \ MSSQL \ Data, and have never been read-only just this last.

  • Hello, I'm receiving this error also. I'm trying to attach some databases that came with the MCTS 70-433 Exam Training Kit. After copying the databases from the CD to my hard drive, two of the databases attached fine. But a third, which required I copy an .ldf file, an .mdf file, and a documents folder, will not attach. The error message says that it cannot find the Documents file specified. Which is weird, because it's in the same place as the data files. It's looking for '\MSSQL10.MSSQLSERVER\MSSQL\DATA\DOCUMENTS' but the default name of the program file given (which I can't/don't know how to change) is '\MSSQL10_50MSSQLSERVER\MSSQL\DATA....'

    Just trying to learn SQL Server after learning Oracle.

    Any help on this? I'm running Windows 7, SQL Server 2008 R2. And I've logged in Windows Authentication mode. Thanks in advance.

  • Please post new questions in a new thread. Thanks

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 1 through 15 (of 26 total)

You must be logged in to reply to this topic. Login to reply