How do I run a localDB instance in single-user mode?

Mads 6 Reputation points
2020-09-29T19:12:23.273+00:00

I am trying to restore the master db of a localDB server instance in SQL Server 2016. I cannot seem to figure out how to run the server in single-user mode so I can restore the master in SSMS. I know I can run the db with SQLLocalDB.exe but this does not specify a single-user argument option. When i run the following command:

C:\Program Files\Microsoft SQL Server\130\LocalDB\Binn> .\sqlservr.exe -c -m -S "(localdb)\MSSQLLocalDB"

I get an error that the "parent instance name exceeds maximum length".

I also tried the query SET SINGLE_USER, but i just get an error that i cannot do this with the master.

Does anyone know how to run this localdb instance in single-user mode, so I can restore the master db from a .bak file?

Thanks

SQL Server | Other
{count} vote

3 answers

Sort by: Most helpful
  1. Olaf Helper 47,586 Reputation points
    2020-09-30T09:33:15.49+00:00

    I am trying to restore the master db of a localDB server instance in SQL Server 2016.

    I don't understand what you try to achieve here? LocalDB don't have system database as the classic SQL Server; so what you want to restore here or what is your issue for that you want to restore here?

    1 person found this answer helpful.
    0 comments No comments

  2. CathyJi-MSFT 22,406 Reputation points Microsoft External Staff
    2020-09-30T08:55:27.497+00:00

    Hi @Mads ,

    It seems we can’t use sqlservr.exe file to start SQL LocalDb. We can start SQL server database engine using sqlservr.exe file. Please refer to Start LocalDB and connect to LocalDB.

    The SqlLocalDB utility (SqlLocalDB.exe) is a simple command line tool to enable users and developers to create and manage an instance of SQL Server Express LocalDB. But –m parameter is not supported. Please refer to SqlLocalDB Utility.

    It seems the Start SQL Server in Single-User Mode document is supported for Database engine not LocalDB.
    29374-screenshot-2020-09-30-164356.jpg

    Bet regards,
    Cathy


    If the response 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.

    0 comments No comments

  3. Erland Sommarskog 129.1K Reputation points MVP Volunteer Moderator
    2020-09-30T21:16:48.16+00:00

    My own installation of sqllocaldb is broken to the extent that I cannot even get the help messages. Thus, I cannot test what I'm suggesting.

    But you could restore your backup on another instance (as a regular user database), detach the files and then put them in the location of the current database files for your localdb instance. If your localdb instance is running, you restore the backup to this instance - again as a user database and detach.

    Don't delete the current files for your master database - I can't guarantee that the above will work, it is just an idea for you to try.

    0 comments No comments

Your answer

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