【问题标题】:Not able to restore databases from blob container using T-SQL无法使用 T-SQL 从 Blob 容器还原数据库
【发布时间】:2019-09-12 12:31:16
【问题描述】:

我正在将我的数据库备份到 Azure Blob 存储。我能够从维护计划中备份和恢复。但是我无法使用脚本恢复数据库。下面是我正在使用的 T-SQL:

RESTORE DATABASE database_name
FROM URL = 'https://StorageAccount.blob.core/Container/FileName.bak'
WITH CREDENTIAL   = 'https://StorageAccount.blob.core.windows.net/Container', STATS = 10

我收到此错误:

消息 3225,第 16 级,状态 1,第 1 行
使用 WITH CREDENTIAL 语法对包含共享访问签名的凭据无效。

消息 3013,第 16 级,状态 1,第 1 行
RESTORE DATABASE 异常终止。

你能帮忙吗?

【问题讨论】:

    标签: azure-blob-storage restore sql-server-2017


    【解决方案1】:

    您的凭据错误,请点击此链接至create a credential

    CREATE CREDENTIAL mycredential   
    WITH IDENTITY= 'msftutorialstorage', -- this is the name of the storage account you specified when creating a storage account   
    SECRET = '<storage account access key>' -- this should be either the Primary or Secondary Access Key for the storage account
    

    然后在您的恢复代码中,使用此凭据,如下所示:

    RESTORE DATABASE AdventureWorks2016 
    FROM URL = 'https://msftutorialstorage.blob.core.windows.net/sql-backup/AdventureWorks2016.bak' 
    WITH CREDENTIAL = 'mycredential',
    STATS = 5 -- use this to see monitor the progress
    GO
    

    【讨论】:

    • 我现在可以使用脚本进行备份-恢复,谢谢。
    • 您好,您能帮忙将其标记为答案吗?谢谢。
    • 您好,能否将其标记为答案?按照这个link :要将答案标记为已接受,请单击答案旁边的复选标记以将其从灰色切换为已填充。谢谢。
    • 我已经评论说这解决了我的问题。如何将此标记为答案?
    • @IftekharIlm,发生了什么?
    猜你喜欢
    • 2019-05-28
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 1970-01-01
    • 1970-01-01
    • 2014-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多