使用mssql-scripter备份Azure AD认证数据库对象遇登录失败问题
问题原因与解决方案
mssql-scripter支持Azure Active Directory(AD)认证,并非只能用Windows认证,你的操作错误在于未指定正确的Azure AD认证方式,导致工具误解析了登录凭证。
错误原因
当你用-U传递Azure AD邮箱格式的用户名、-P传递密码时,工具默认采用SQL Server身份认证逻辑处理,误将邮箱中的域名部分(my_mail_domain)识别为目标服务器名称,从而抛出"无法打开服务器'my_mail_domain'"的登录失败错误。
正确操作方式
根据你的Azure AD认证类型,选择对应命令:
1. Azure AD密码认证
添加--authentication-method ActiveDirectoryPassword参数明确认证方式,完整命令示例:
mssql-scripter -S server.database.windows.net -d database -U user@domain.com -P password -f destination --file-per-object --authentication-method ActiveDirectoryPassword
2. Azure AD集成认证
如果你的本地Windows账号已关联Azure AD身份,可直接使用集成认证,无需输入密码:
mssql-scripter -S server.database.windows.net -d database -f destination --file-per-object --authentication-method ActiveDirectoryIntegrated
注意:Azure SQL服务器地址需填写完整的FQDN(格式如
xxx.database.windows.net),不能仅简写服务器名。
内容的提问来源于stack exchange,提问作者Tempei4
相关产品推荐
相关产品推荐

