Home  >  Article  >  Database  >  当恢复sqlserver bak文件时,原始的用户无法删除的解决方法

当恢复sqlserver bak文件时,原始的用户无法删除的解决方法

WBOY
WBOYOriginal
2016-06-07 18:00:221136browse

当你从现有的bak文件,恢复数据库时,如果数据库本身带有一个用户:比如用户叫:DemoUser.

你无法创建一个相同的用户并mapping这个用户到数据库, 并且你无法删除数据库的用户:DemoUser.
请运行以下脚本, 之后你就可以删除用户:DemoUser.然后创建用户(DemoUser.)并mapping到数据库。
脚本:
代码如下:
GO
ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_BasicAccess] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_FullAccess] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON ROLE::[aspnet_Membership_ReportingAccess] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON ROLE::[aspnet_Profile_BasicAccess] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON ROLE::[aspnet_Profile_FullAccess] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON ROLE::[aspnet_Profile_ReportingAccess] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON ROLE::[aspnet_Roles_BasicAccess] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON ROLE::[aspnet_Roles_FullAccess] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON ROLE::[aspnet_Roles_ReportingAccess] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON SCHEMA::[db_owner] TO [dbo]
GO
GO
ALTER AUTHORIZATION ON SCHEMA::[db_owner] TO [db_owner]
GO
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn