SQL 将数据库更改为“在线”并将数据库设置为“多用户”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6587360/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
change to database to 'online' and set db to 'multi-user'
提问by FiveTools
I have a 2008 sql database that is offline that I would like to take online and set to multi-user. Using sql server management studio - new query window - when i execute the following:
我有一个离线的 2008 sql 数据库,我想将其联机并设置为多用户。使用 sql server management studio - 新查询窗口 - 当我执行以下操作时:
ALTER DATABASE mydb SET ONLINE;
ALTER DATABASE mydb SET MULTI_USER;
I receive this error message:
我收到此错误消息:
Msg 5064, Level 16, State 1, Line 1 Changes to the state or options of database 'mydb' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.
Msg 5069, Level 16, State 1, Line 1 ALTER DATABASE statement failed. Msg 5064, Level 16, State 1, Line 3 Changes to the state or options of database 'mydb' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it. Msg 5069, Level 16, State 1, Line 3 ALTER DATABASE statement failed.
消息 5064,级别 16,状态 1,第 1 行此时无法更改数据库 'mydb' 的状态或选项。数据库处于单用户模式,当前有用户连接到它。
消息 5069,级别 16,状态 1,第 1 行 ALTER DATABASE 语句失败。消息 5064,级别 16,状态 1,第 3 行此时无法更改数据库“mydb”的状态或选项。数据库处于单用户模式,当前有用户连接到它。消息 5069,级别 16,状态 1,第 3 行 ALTER DATABASE 语句失败。
How would I get the database online and in multi-user mode?
如何使数据库联机并处于多用户模式?
采纳答案by Aaron Bertrand
Make sure you are not IN that database. Close any query windows that are connected to it, shut down Object Explorer Details, close SSMS and re-open it without Object Explorer connected to that server, etc. Run this:
确保您不在该数据库中。关闭连接到它的所有查询窗口,关闭对象资源管理器详细信息,关闭 SSMS 并在没有对象资源管理器连接到该服务器的情况下重新打开它,等等。运行以下命令:
USE [master];
GO
ALTER DATABASE mydb SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
That should allow you to bring it online, then you would run the commands you listed.
这应该允许您将其联机,然后您将运行您列出的命令。
回答by Nelson
Well, I stopped that particular database service in Administrator Tools > Services. Then, right clicked on Database server to get options and then changed the staus to multiuser mode.
好吧,我在管理员工具 > 服务中停止了那个特定的数据库服务。然后,右键单击数据库服务器以获取选项,然后将状态更改为多用户模式。