SQL 如何将数据库备份到 .bak 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/883675/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I back up a database to a .bak file?
提问by andyhky
I have a website I've created in Visual Studio 2008 and I need to take it live. How can I backup the database file to a .bak so I can hand it over to the hosting company to place on the server?
我有一个在 Visual Studio 2008 中创建的网站,我需要将其上线。如何将数据库文件备份到 .bak 以便我可以将其交给托管公司以放置在服务器上?
回答by andyhky
From a SQL prompt:
从 SQL 提示符:
BACKUP DATABASE MyDatabase TO DISK='E:\MyDatabase.bak'
回答by Nathan Koop
Go to Microsoft Server Management Studio and right click on your database name. Go to "Tasks" -> "Back Up..."
转到 Microsoft Server Management Studio 并右键单击您的数据库名称。转到“任务”->“备份...”
Then assign your properties, ensure that "Backup Type" is full.
然后分配您的属性,确保“备份类型”已满。
Then at the right there is a button "Add" press that and set your filename, ensure that you place the extension .bak at the end of the file name.
然后在右侧有一个“添加”按钮,按下它并设置您的文件名,确保将扩展名 .bak 放在文件名的末尾。
Finally hit ok and wait for the backup to complete.
最后点击确定并等待备份完成。
MSDN also has an article that explains this http://msdn.microsoft.com/en-us/library/ms187510.aspx
MSDN 也有一篇文章解释了这个http://msdn.microsoft.com/en-us/library/ms187510.aspx
回答by kscott
In ssms right click on the database, go to tasks, click back up. should be self explanatory from there.
在 ssms 中右键单击数据库,转到任务,单击备份。从那里应该是不言自明的。
回答by Mehrdad Afshari
You don't need a backup to do so (I assume you are using the AttachDbFilename
model that Visual Studio uses by default). Just send them the mdf
and tell them to attach it to their SQL server instance.
您不需要备份来这样做(我假设您使用的AttachDbFilename
是 Visual Studio 默认使用的模型)。只需向他们发送mdf
并告诉他们将其附加到他们的 SQL 服务器实例。
回答by NinethSense
I assume you use SQL Server. This links will guide you:
我假设您使用 SQL Server。此链接将指导您:
How to: Back Up a Database (SQL Server Management Studio):
如何:备份数据库 (SQL Server Management Studio):