can't attach database with remote mdf file

Hui Wang 1 Reputation point
2020-10-28T10:22:54.93+00:00

I want to attach database using mdf file. The mdf file is not in local computer. It can be access using window file explorer with address like \nbapp637...\model.mdf with username and password. And I also add the username and password to credential manager. But when I attach the database, it fails with error . It seems that mssql can not get the username and password in credential manager, so that can't attach the database.
35704-%E5%9B%BE%E7%89%87.png

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,627 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Shashank Singh 6,251 Reputation points
    2020-10-28T10:28:00.9+00:00

    What is stopping you from copying the mdf and ldf files locally and attaching. SQL Server engine would need permission on folder where mdf resides. It would need read and write permission. In your case that is not possible. I would suggest copy it locally and attach. Is this AWS ?

    0 comments No comments

  2. AmeliaGu-MSFT 13,976 Reputation points Microsoft Vendor
    2020-10-29T02:20:58.073+00:00

    Hi @Hui Wang ,

    Could you please check if the SQL Server service account has enough rights to read/write this sharing file?
    Or you can try to copy the files to default location for Database Engine data files (\Program Files\Microsoft SQL Server\MSSQL1x. \MSSQL\DATA).
    Please refer to this similar thread which might help.

    Best Regards,
    Amelia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    Users always get connection timeout problem when using multi subnet AG via listener. Especially after failover to another subnet

    0 comments No comments

  3. Ben Miller (DBAduck) 956 Reputation points
    2020-10-29T02:33:52.757+00:00

    You are right. SQL Server will not be able to get the credential and use it to get to the share for the SQL Server database file. You need to either configure it so that the SQL Server service account has access to the file on the share without using a username / password or you need to figure out another way (copy it locally or otherwise)

    Shares require Windows Auth access by the SQL Server service account.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.