Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete the localdb instance owned by System

I deleted the localdb instance files which were located in

"C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0"

by accident. The system cannot start the localdb instance now. The way that I know how to fix the issue is to delete the instance by command

"sqllocaldb delete instancename"

, and re-create the instance again. But I found this approach could only work for user account if I deleted the instances files located in

"C:\Users\UserName\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0"

So how can I solve this problem to delete the db instance owned by System?

like image 296
yushulx Avatar asked Dec 20 '13 08:12

yushulx


People also ask

How do I delete a LocalDB instance?

In order to be deleted, first it should be stopped. Type the SqlLocalDB stop MSSQLLocaDB command in the Command Prompt window: LocalDB instance “MSSQLLocalDB” stopped. Now, repeat the SqlLocalDB delete MSSQLLocalDB command.

Where is LocalDB stored?

Once installed, LocalDB is an instance of SQL Server Express that can create and open SQL Server databases. The system database files for the database are stored in the local AppData path, which is normally hidden.

How do you check if I have LocalDB installed?

Open "Command Prompt" Type line "sqllocaldb info" and check the name. By default, it will show "MSSQLLocalDB".


1 Answers

Get PsExec from here: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

Run cmd.exe as LocalSystem as demonstrated in this link: How do you run CMD.exe under the Local System Account? psexec -i -s cmd.exe

Now you can run SqlLocalDb stop InstanceName and SqlLocalDb delete InstanceName

like image 162
Novaterata Avatar answered Sep 28 '22 11:09

Novaterata