我们一直使用VS2012扩展使用.sqlproj进行数据库设计和开发,并使用DACPAC使用SQLPackage部署到Server。或者从Visual设置发布规则。
我们已经将数据库迁移到Amazon Server。
我们最近对数据库设计做了一些更改,我试图发布这些更改,并得到了这个错误。
Error SQL72014: .Net SqlClient Data Provider: Msg 15151, Level 16, State 1, Line 1 Cannot find the user 'dbo', because it does not exist or you do not have permission.
Error SQL72045: Script execution error. The executed script:
REVOKE INSERT
ON OBJECT::[dbo].[table_name] TO [database_role] CASCADE
AS [dbo];我到处搜索如何将这种类型的数据库项目发布到Amazon,除了通过维护模式的本地Server数据库和购买Red比较来迁移更改之外。我很困惑..。
如有任何建议,将不胜感激。
发布于 2014-06-06 04:40:09
简单的答案是,我们可以使用sqlpackage命令行,或者sqlproj发布函数来更新amazon数据库,就像在任何其他服务器上使用它一样。
我遇到的问题似乎是由于没有声明和配置实例sa用户(您第一次在Amazon上创建SQL实例时设置的Amazon实例的主sa帐户)。
由于我没有在数据库中声明用户及其角色成员资格,因此从数据库中删除了它的db_owner角色成员资格,在此之后似乎不可能重新创建它。
因此--如果您在执行部署时出错并破坏了目标数据库上的sql dbo权限--解决方案是进入Amazon控制台,查找SQL实例,修改实例,并更改设置的新主密码(即使它与现有密码相同),然后在底部勾选框以立即应用。(这是亚马逊支持团队提供的说明-今天上午我在研究、试验和错误过程中已经做了很多次了。)
在不破坏安全性的情况下部署升级的关键部分如下。
CREATE LOGIN [myusername] with password = 'mypassword';- myinstancesa - this is the exact same name as the sa account you created when you defined the instance.
- myappuser - this is the user that I will use in my application connection string so that my application does not run as the sa account and I can implement security at the database level to enforce or limit the ability of the application to accidentally delete or update certain tables..
CREATE ROLE [myapp_role] AUTHORIZATION [dbo];,然后将成员资格授予我的应用程序用户给这个角色EXECUTE sp_addrolemember @rolename = N'myapp_role', @membername = N'myappuser';。GRANT INSERT ON OBJECT::[mytable] TO [myapp_role]CREATE USER [myinstancesa] FOR LOGIN [myinstancesa] WITH DEFAULT_SCHEMA = dbo的用户。EXECUTE sp_addrolemember @rolename = N'db_owner', @membername = N'myinstancesa';sqlpackage.exe /a:Publish /sf:mysnapshot.dacpac /tsn:long.instance.id.and.name.amazon.com /tu:myinstancesa /tp:"password in quotes" /tdn:myTargetDatabaseName /p:DropPermissionsNotInSource=True /p:DropRoleMembersNotInSource=false /p:BlockOnPossibleDataLoss=false /p:DropConstraintsNotInSource=true /p:DropExtendedPropertiesNotInSource=true /p:DropIndexesNotInSource=true /p:DropObjectsNotInSource=true /p:GenerateSmartDefaults=true /p:IgnoreIdentitySeed=true /p:IgnoreIncrement=true /p:IgnoreLoginSids=true /p:IgnoreWithNocheckOnForeignKeys=true /p:VerifyDeployment=true /v:Master=master.dacpacmysnapshot.dacpac必须是快照的完整路径或相对路径,还必须创建主项目的快照,并将完整路径或相对路径包含为最后一个变量(并不总是需要是最后一个变量)。tsn是Amazon控制台中命名的端点,tdn是目标数据库名,我在引号中输入的密码是为了防止有特殊字符或穿孔字符。
https://stackoverflow.com/questions/23802146
复制相似问题