How do I change “Database default locations” for LocalDB in SQL Server Management Studio?

梦想的初衷 提交于 2020-12-30 04:52:03

问题


  1. Connect to LocalDB in SSMS
  2. Open Server Properties -> Database Settings enter image description here
  3. Change Data/Log/Backup locations -> click OK

When I click OK I get this error: enter image description here

Found some blogpost and changed this in regedit but it didn't help. enter image description here

Anyone got any other ideas I could try?


回答1:


I do not believe that these default paths for SQL Server LocalDB are changeable. This is quite unfortunate due to what appears to be a bug with SQL Server Express 2017 LocalDB ** (fixed as of CU 6 for SQL Server 2017), as per this question (and my answer to it) on DBA.StackExchange:

LocalDB v14 creates wrong path for mdf files

HOWEVER, you do not need to use the default paths. Those are used when you create a Database without specifying the physical locations. If you specify the physical location, then you should be able to create the files to any folder / directory that you have read / write access to.




回答2:


After making that change in the registry try restarting the sql instance. Also I would make sure that the account running SQL Server has the ability to write to that folder. for an easy test you could go to the folder properties -> security then add the account 'everyone' then give them full control. then try making that change. If it works it was a permissions issue to that account. Accounts generally don't have access to other users accounts without some level of admin.




回答3:


I think one of the purposes of LocalDB is that it is very convinient in bundling a demo database along with the source files of an application. The database file and its log, of course, are somewhere in the source file directory.

Take a Visual Studio solution for example, in web.config or app.config, you can see something like this:

<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-XXXXXX-20140609153630;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-XXXXXX-20140609153630.mdf" providerName="System.Data.SqlClient" />

Now that the location of every LocalDB is specified in the config file, I don't think "default location" makes much sense.



来源:https://stackoverflow.com/questions/13778034/how-do-i-change-database-default-locations-for-localdb-in-sql-server-managemen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!