I get multiple errors with LocalDB (startup error, can't create DB from SQL Server Management Studio and also multiple issues when trying to restore a backup) and none of the fixes I found are helping anything. It seems to me that all errors have their root in permissions not set up correctly.

Now a simple DDL table creation script works fine from SQL Server Management Studio and creates the database in the root of my user account's folder (as explained here). The Instances folder however (located at D:\Users\[My name]\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances despite when installing the SQL Server Express with Advanced Services I specified the DATA folder in another location - where only standard SQL Server Express .mdf files are stored, but not LocalDB instances) seems problematic regarding permissions (in contrary to the account root) therefore and also for having my DB files in a location among my projects I'd like to move the Instances folder to another place. Is this possible? I haven't even found a corresponding registry entry.

I'm using SQL Server Express 2012 and also SSMS of the same version (latest updates installed).

Any help would be appreciated.

Edit: The Database Settings page KookieMonster mentioned previously threw an error for me, not being able to edit nor see any configuration there. I let Windows Update check for updates again and there were some updates for SQL Server Express that weren't installed (although I'm sure I selected everything to install before), so I installed them. This made it possible for me to go to the settings page.

I've tried to set up the LocalDB instance's root folder to somewhere else but I get an access denied error for every folder I tried, namely

Alter failed for Settings 'Microsoft.SqlServer.Management.Smo.ObjectKeyBase'. (Microsoft.SqlServer.Smo)

------------------------------ ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

RegCreateKeyEx() returned error 5, 'Access is denied.' (Microsoft SQL Server, Error: 22002)

I get this even if the folder has Full control set for Everyone! Even more amusing the only folder that works, one that is set as a default (the user account's root) has no special permissions applied - just the ones my user has (just as any other folder I tried to set). In effect this means that all my LocalDB databases' files are saved to my account's root folder.

  • 1
    What happens when you create a database and explicitly set the files to a specific location instead of taking the defaults? – Aaron Bertrand Apr 7 '13 at 11:05
  • 1
    Thanks for your reply! That works (if I select a suitable folder like my project folder) but it's very inconvenient to have to specify the path every time. I just can't believe there's no way to change the defaults. – Piedone Apr 7 '13 at 23:39
  • What happens when you go to the server node, right click, properties, database parameters and switch the default location? Are the values the one you set during the install or something else? – KookieMonster Apr 8 '13 at 11:01
  • I've been having the exact same problem. I think the reason changing folder permissions don't have an effect is because this is actually telling you there's a permissions problem with the registry, specifically creating a registry key (see the last part: RegCreateKeyEx). Unfortunately I can't figure out what key it wants to create. – daveaglick Mar 20 '14 at 19:05

See my comment above. I used Process Monitor to trace the registry access and found it was getting an Access Denied while trying to write:

3:16:40.8405491 PM sqlservr.exe 8756 RegCreateKey HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer ACCESS DENIED Desired Access: Write

I got around this by opening the Registry Editor and giving Everyone full access to HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer. Then I changed the default location and removed the Everyone access once it was done. This made the following extra keys that weren't there before:




  • Thank you. I've gone a different route in the end, so can't test how this would work for me. – Piedone Mar 20 '14 at 20:07
  • 4
    I just tried exactly the solution you proposed here and yes I have got the extras you mentioned in the registry. Still this does not override or change the current properties values of my local database. The registry shows the desired values for all 3 locations, but in SMSS there are still the default locations by installation. Using MS sql server compact 3.5 SP 1 could be the reason for such a behavior? – user3840527 Jan 11 '15 at 10:31
  • 3
    This is the only place that I've been able to find any info about this error. somedave, yes, altering the permissions for that reg key does make the error go away, but as user3840527 says, SSMS still has the original default locations afterwards, even after exiting & reopening it. – Yann Duran Jan 30 '15 at 6:36
  • @Piedone, could you please possibly explain what is was that you did instead of using the reg key method? Or point to somewhere that explains the method? Thanks – Yann Duran Jan 30 '15 at 6:38
  • 1
    Error goes away but the location does not change – Adil Mammadov Aug 26 '17 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.