How to fix MSSQLLocalDB?
Asked Answered
L

4

7

On my machine MSSQLLocalDB got corrupted:

    PS C:\WINDOWS\system32> sqllocaldb i
    MSSQLLocalDB
    Projects
    ProjectsV12
    v11.0
    PS C:\WINDOWS\system32> sqllocaldb i mssqllocaldb
    The required LocalDB version "0.0" is not installed.
    PS C:\WINDOWS\system32>

Is there anything I can do short of reinstalling Visual Studio / Sql Server / Sql Express to fix it?

I should mention that any Visual Studio functionality that is dependent on LocalDb is not working because of this, for example CodeMaps

Lowminded answered 9/11, 2015 at 5:26 Comment(0)
C
24

This can occur if you've just installed LocalDB and haven't started the instance yet. I'm not sure if rebooting would have restarted it for me (I imagine it would have), but the following worked without needing to:

C:\Users\sweaver>sqllocaldb.exe s MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" started.

That should be all you need - but here is the full diagostics steps I used in the process.


This is before installing new version of LocalDB (2014)

C:\Users\sweaver>sqllocaldb.exe i
v11.0

Afterwards

C:\Users\sweaver>sqllocaldb.exe i
MSSQLLocalDB
v11.0

Then I immediately get this error

C:\Users\sweaver>sqllocaldb.exe i MSSQLLocalDB
The required LocalDB version "0.0" is not installed.

Strange! What about version 11 - that's ok

C:\Users\sweaver>sqllocaldb.exe i v11.0
Name:               v11.0
Version:            11.0.5343.0
Shared name:
Owner:              RR2014\sweaver
Auto-create:        Yes
State:              Running
Last start time:    3/10/2016 3:00:29 PM
Instance pipe name: np:\\.\pipe\LOCALDB#60C1AC49\tsql\query

Here's the versions

C:\Users\sweaver>sqllocaldb.exe v
Microsoft SQL Server 2012 (11.0.5343.0)
Microsoft SQL Server 2014 (12.0.2000.8)

Let's try starting it

C:\Users\sweaver>sqllocaldb.exe s MSSQLLocalDB
LocalDB instance "MSSQLLocalDB" started.

And try again...

C:\Users\sweaver>sqllocaldb.exe i MSSQLLocalDB
Name:               MSSQLLocalDB
Version:            12.0.2000.8
Shared name:
Owner:              RR2014\sweaver
Auto-create:        Yes
State:              Running
Last start time:    3/10/2016 3:10:55 PM
Instance pipe name: np:\\.\pipe\LOCALDB#1D3F49F3\tsql\query

Phew! That was easy!

Clareclarence answered 10/3, 2016 at 23:28 Comment(0)
L
5

What I ended up doing follows. Note, that I'm sure this is not a correct way of doing this, but rather a messy hack. It allowed me getting my CodeMaps working again though, so I'm happy.

I deleted the mssqllocaldb

sqllocaldb d mssqllocaldb

The system won't let me create it again so I created another one:

sqllocaldb с mssqllocaldb1

I went to "C:\Users\[username]\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\" and backed up MSSQLLocalDB folder. Then I copied MSSQLLocalDB1 folder to MSSQLLocalDB.

In registry I found the new instance under HKCU\Software\Microsoft\Microsoft SQL Server\UserInstances\ and changed the DataDirectory value to reflect the new path, that is to end with MSSQLLocalDB instead of MSSQLLocalDB1.

After that I was able to start MSSQLLocalDB successfully and CodeMaps worked:

PS C:\WINDOWS\system32> sqllocaldb s mssqllocaldb

LocalDB instance "MSSQLLocalDB" started.

Lowminded answered 9/11, 2015 at 21:53 Comment(0)
U
1

I fixed the issue by deleting the folder and a reg key. Followed by an install.

Delete the folder

C:\Users\username\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB

Delete the registry key that has MSSQLLocalDB like HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SQL Server\UserInstances{B0A12082-AC5B-4E05-A0C9-ABFB6816EE16}

Running from cmd

C:>sqllocaldb c MSSQLLocalDB

LocalDB instance "MSSQLLocalDB" created with version 13.0.2151.0.

Unstudied answered 19/11, 2016 at 0:45 Comment(0)
A
0

I just updated the registry key GUID under HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\UserInstances\ to the correct value of ParentInstance which was working for me. Usualy this happens when you upgrade to higher versions. I have to change ParentInstance value from MSSQL12E.LOCALDB to MSSQL13E.LOCALDB

Aras answered 28/2, 2018 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.