如何防止SQL Server LocalDB自动关闭?
我正在使用 SQL Server 2012 Express LocalDB。如果实例没有任何活动,它们似乎会在 10 分钟后自动停止。有没有一种干净的方法可以让实例永远运行?
I'm using SQL Server 2012 Express LocalDB. Instances seem to stop automatically after 10 minutes if there is no activity on them. Is there a clean way to keep an instance running forever?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
超时是可以通过T-SQL配置的,
'用户实例超时'
选项:超时以 minute 表示,并且具有
65535的最大值
。我敢肯定,设置实例后您需要重新启动该实例。并且不要尝试将其设置为0
,它将仅在启动后立即关闭实例,这将使很难将值设置回有用的东西:-)。来源:此bol文章也要对LocalDB实例。
最终备注
如果您需要始终运行并在计算机启动时启动的东西,则可能只考虑使用常规,基于服务的,SQL Server Express的实例。
The timeout is configurable via T-SQL with
'user instance timeout'
option:The timeout is expressed in minutes and has a maximum value of
65535
. I'm pretty sure you need to restart the instance after setting it. And don't try setting it to0
, it will just make the instance shut down immediately after starting, which will make it hard to set the value back to something useful :-).Source: this BOL article containing other useful information on User Instances that are applicable to LocalDB instances as well.
Final Remark
If you need something that's always running and starts whenever a computer starts you might just consider using regular, service-based, instance of SQL Server Express.
这是如何从命令行中做Krzysztof Kozielczyk的回答。
启动
localdb
实例。获取服务器路径,这是实例管道名称。
在该服务器上运行SQL命令。
Here is how to do Krzysztof Kozielczyk's answer from the command line.
Start the
localdb
instance.Get the server path, which is the Instance pipe name.
Run an SQL command on that server.