[英]How to fix a mysql dump file if it has blob field but dump without use --hex-blob parameter?
[英]How to import a dumb file to Azure DB on mySQL Server, the dump resides in the blob. How can I dynamically access the blob file
我的power shell代码,将转储文件从azure存储下载到我的本地驱动器。 Get-AzureStorageBlobContent -Container $storagecontainername -Blob $backupfilename -Destination $restorefilename
使用本地驱动器中的转储文件进行导入。 get-content $restorefilename | &"$mysqlpath" -h $servername -u $username -p $password $database
我希望直接用blob文件替换这个$restorefilename
。
没有内置的cmdlet。
您可以在powershell中使用一些.net方法直接将blob文件下载为字符串。
注意:如果blob存储是公共的,您可以直接使用它的url。 如果blob存储是私有的,则应为blob生成SAS令牌。
公共blob的示例代码如下:
$client = New-Object System.Net.WebClient
$client.DownloadString("https://xxx.blob.core.windows.net/f22/t1.txt")
测试结果如下:
所以在你的情况下,你可以写下面的东西:
$client = New-Object System.Net.WebClient
$restorefilename = $client.DownloadString("https://xxx.blob.core.windows.net/f22/t1.txt")
$restorefilename | &"$mysqlpath" -h $servername -u $username -p $password $database
如果您的blob是私有的,您可以按照下面的屏幕截图生成一个用于下载的sas URL:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.