简体   繁体   English

如何从 Mac 上的 azure 数据工作室的 bak 文件恢复数据库

[英]How to restore a database from bak file from azure data studio on Mac

Previously on Mac I use mysql operation studio and I click on database and click restore then browse to my bak file, but now they change to azure data studio and when I repeat the same steps I got this error: "You must enable preview features in order to use restore"以前在 Mac 上,我使用 mysql operation studio,然后单击数据库并单击恢复,然后浏览到我的 bak 文件,但现在它们更改为 azure data studio,当我重复相同的步骤时,我收到此错误:“您必须在为了使用恢复“ 在此处输入图片说明 but I cannot figure out hot to enable that.但我无法弄清楚启用它的热度。 I have googled and tried few things even open my azure, microsoft account on website but I do not see that option.我已经用谷歌搜索并尝试了几件事,甚至在网站上打开我的 azure 微软帐户,但我没有看到该选项。 Can some one help please !有人可以帮忙吗!

  • Go to Azure Data Studios > Settings转到 Azure 数据工作室 > 设置
  • Edit settings by clicking on "new settings editor"通过单击“新设置编辑器”来编辑设置
  • Search for "preview"搜索“预览”
  • Scroll to the bottom and check "Enable unreleased preview features"滚动到底部并选中“启用未发布的预览功能”

Adding this as an answer as I don't have enough rep to comment.添加此作为答案,因为我没有足够的代表发表评论。 This is in response to the question in the comment for the answer to the OP (If that's not confusing enough!)这是对 OP 答案评论中的问题的回应(如果这还不够混乱!)

This only applies when your sql database is hosted on a Mac/Linux/Docker Container.这仅适用于您的 sql 数据库托管在 Mac/Linux/Docker 容器上的情况。 We don't have any Windows servers in our estate for me to test this on to see if the location of the .bak files is any different.我们的资产中没有任何 Windows 服务器供我测试以查看 .bak 文件的位置是否有任何不同。

When you click on the "..." button, it browses to /var/opt/mssql/data on the machine (or docker container) the database is hosted on.当您单击“...”按钮时,它会浏览到托管数据库的机器(或 docker 容器)上的 /var/opt/mssql/data。 This is not an issue if you are backing up & restoring databases on the same host, however, if you're migrating to a new server or just creating a dev/UAT/staging environment, it becomes a problem because you don't have access to var/opt/mssql/data.如果您在同一台主机上备份和恢复数据库,这不是问题,但是,如果您要迁移到新服务器或只是创建开发/UAT/登台环境,这将成为一个问题,因为您没有访问 var/opt/mssql/data。

This is a bit of a sledgehammer to crack a nut type solution but as I'm working with 2 dev boxes, it doesn't make a lot of difference to me.这是破解坚果类型解决方案的大锤,但是当我使用 2 个开发盒时,它对我没有太大影响。

To make this easier to understand I'll call the server that hosts the database you have backed up ProdServ & the server you are restoring to DevServ .为了使这更容易理解,我将调用托管您已备份ProdServ的数据库的服务器和您要恢复到DevServ的服务器。

On DevServ, at a terminal prompt, navigate to /var/opt and make a note of the current permissions on the mssql directory (mine were drwxrwx---).在 DevServ 上,在终端提示下,导航到 /var/opt 并记下 mssql 目录的当前权限(我的是 drwxrwx---)。

$ cd /var/opt

$ ls -la

Google the octal value for your permissions (in my instance, it's 770)谷歌你的权限的八进制值(在我的例子中,它是 770)

Change the permissions of the data directory to rwxrwxrwx.将数据目录的权限更改为 rwxrwxrwx。

$ chmod -R 777 /var/opt/mssql/data

(You will also need to do this on ProdServ if that is also a Unix-based o/s) (如果 ProdServ 也是基于 Unix 的 o/s,您还需要在 ProdServ 上执行此操作)

Copy the .bak files from ProdServ to DevServ via a method suitable to the environment you're working in.通过适合您工作环境的方法将 .bak 文件从 ProdServ 复制到 DevServ。

Windows --> Linux I'd use WinSCP Windows --> Linux 我会使用 WinSCP

For Mac to Docker, docker cp <fileToCopy> <container>:<destinationPath> works perfectly fine.对于 Mac 到 Docker, docker cp <fileToCopy> <container>:<destinationPath>工作得很好。

Once the files have been copied over, they will magically appear when you click the "..." button in azure data studio again.复制文件后,当您再次单击 azure data studio 中的“...”按钮时,它们会神奇地出现。 Make sure you change the directory permissions back to their original value via the same command.确保通过相同的命令将目录权限更改回其原始值。 So in my instance, simply所以在我的例子中,简单地

$ chmod -R 770 /var/opt/mssql/data

As an extra note, if you're used to working in MSSMS, the wizard there allows you to create a database from a .bak file, from what I can see, Azure Data Studio does not.额外说明一下,如果您习惯于在 MSSMS 中工作,那里的向导允许您从 .bak 文件创建数据库,据我所知,Azure Data Studio 没有。 You have to create the database first ( CREATE DATABASE <databasename> ) in a query window, then restore the .bak file to it.您必须首先在查询窗口中创建数据库 ( CREATE DATABASE <databasename> ),然后将 .bak 文件还原到其中。

简单地将其添加到您的设置文件中:

"workbench.enablePreviewFeatures": true

You can click on View at the top menu next to Window.您可以单击窗口旁边顶部菜单中的查看。 Then select the first option Command Palette Then in the command textbox type Restore and select Restore Then the restore window comes up.然后选择第一个选项Command Palette 然后在命令文本框中键入Restore 并选择Restore 然后恢复窗口出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM