简体   繁体   English

如何将.bak文件导入Microsoft SQL Server 2012?

[英]How do I import a .bak file into Microsoft SQL Server 2012?

谷歌搜索了一段时间没有答案....任何人都可以帮忙吗?

For SQL Server 2008, I would imagine the procedure is similar...? 对于SQL Server 2008,我会想象程序类似......?

  • open SQL Server Management Studio 打开SQL Server Management Studio
  • log in to a SQL Server instance, right click on "Databases", select "Restore Database" 登录到SQL Server实例,右键单击“数据库”,选择“还原数据库”
  • wizard appears, you want "from device" which allows you to select a .bak file 向导出现,您想要“从设备”,它允许您选择.bak文件

Using the RESTORE DATABASE command most likely. 最有可能使用RESTORE DATABASE命令。 bak is a common extension used for a database backup file. bak是用于数据库备份文件的常用扩展。 You'll find documentation for this command on MSDN . 您可以在MSDN上找到此命令的文档。

Not sure why they removed the option to just right click on the database and restore like you could in SQL Server Management Studio 2008 and earlier, but as mentioned above you can restore from a .BAK file with: 不确定为什么他们删除了右键单击数据库并在SQL Server Management Studio 2008及更早版本中进行恢复的选项,但如上所述,您可以从.BAK文件恢复:

RESTORE DATABASE YourDB FROM DISK = 'D:BackUpYourBaackUpFile.bak' WITH REPLACE

But you will want WITH REPLACE instead of WITH RESTORE if your moving it from one server to another. 但是如果你将它从一个服务器移动到另一个服务器,你将需要WITH REPLACE而不是WITH RESTORE

.bak is a backup file generated in SQL Server. .bak是SQL Server中生成的备份文件。

Backup files importing means restoring a database, you can restore on a database created in SQL Server 2012 but the backup file should be from SQL Server 2005, 2008, 2008 R2, 2012 database. 备份文件导入意味着还原数据库,您可以在SQL Server 2012中创建的数据库上进行还原,但备份文件应该来自SQL Server 2005,2008,2008 R2,2012数据库。

You restore database by using following command... 您可以使用以下命令恢复数据库...

RESTORE DATABASE YourDB FROM DISK = 'D:BackUpYourBaackUpFile.bak' WITH Recovery

You want to learn about how to restore .bak file follow the below link: 您想了解如何恢复.bak文件,请点击以下链接:

http://msdn.microsoft.com/en-us/library/ms186858(v=sql.90).aspx http://msdn.microsoft.com/en-us/library/ms186858(v=sql.90).aspx

You can use the following script if you don't wish to use Wizard; 如果您不想使用向导,可以使用以下脚本;

RESTORE DATABASE myDB
FROM  DISK = N'C:\BackupDB.bak' 
WITH  REPLACE,RECOVERY,  
MOVE N'HRNET' TO N'C:\MSSQL\Data\myDB.mdf',  
MOVE N'HRNET_LOG' TO N'C:\MSSQL\Data\myDB.ldf'

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

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