退出单用户模式 [英] Exit single-user mode

查看:40
本文介绍了退出单用户模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我的数据库处于单用户模式.当我尝试扩展我的数据库时,出现错误:

Currently, my database is in Single User mode. When I try to expand me database, I get an error:

无法访问数据库my_db".(ObjectExplorer)

The database 'my_db' is not accessible.(ObjectExplorer)

此外,当我尝试删除数据库时,出现错误:

Also, when I try to delete the database, I get the error:

无法更改数据库my_db"的状态或选项这次.数据库是单用户模式,一个用户是当前连接到它.

Changes to the state or options of database 'my_db' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.

如何退出单用户模式?我没有任何用户使用这个数据库.

How do I exit out of single-user mode? I don't have any user using this database.

当我尝试使用 IIS 浏览我的网站时,我得到的错误是:

When I try to browse my site with IIS, the error I get is:

在执行过程中产生了一个未处理的异常当前网络请求.有关来源和位置的信息可以使用下面的异常堆栈跟踪来识别异常.

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

我觉得好像是单用户模式导致了这种情况.

I feel as though the single-user mode is causing this.

推荐答案

SSMS 通常在后台使用多个数据库连接.

SSMS in general uses several connections to the database behind the scenes.

您需要在更改访问模式之前终止这些连接.

You will need to kill these connections before changing the access mode.

首先,确保对象资源管理器指向像 master 这样的系统数据库.

First, make sure the object explorer is pointed to a system database like master.

其次,执行 sp_who2 并找到到数据库 'my_db' 的所有连接.通过执行 KILL { session id } 来终止所有连接,其中 session id 是 sp_who2 列出的 SPID.

Second, execute a sp_who2 and find all the connections to database 'my_db'. Kill all the connections by doing KILL { session id } where session id is the SPID listed by sp_who2.

第三,打开一个新的查询窗口.

Third, open a new query window.

执行以下代码.

-- Start in master
USE MASTER;

-- Add users
ALTER DATABASE [my_db] SET MULTI_USER
GO

请参阅我关于管理数据库文件的博客文章.这是为移动文件而写的,但用户管理是一样的.

See my blog article on managing database files. This was written for moving files, but user management is the same.

这篇关于退出单用户模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆