简体   繁体   English

如何通过未知文件在SQL Server中设置数据库?

[英]How to setup database in SQL Server by an unknown file?

Probably this is the lamest question >< 也许这是最棘手的问题> <

I am developing an ASP.net web app with SQL Server database. 我正在使用SQL Server数据库开发ASP.net Web应用程序。 When the client asked me to develop the system, he provided a file for the database. 当客户要求我开发系统时,他提供了数据库文件。

I thought the file was a dumpfile (if you familiar with oracle or mysql, you can replicate database with dumpfile, which is basically bunch of queries inside a text file). 我以为文件是转储文件(如果您熟悉oracle或mysql,则可以使用转储文件复制数据库,该文件基本上是文本文件内的一堆查询)。

To my horror, plus with my noobity in SQL Server, I found out that it was NOT a dumpfile. 令我感到恐惧的是,加上我在SQL Server中的笨拙,我发现它不是转储文件。 The file is rename to .bak which is not really the correct extension for SQL Server. 该文件被重命名为.bak,这实际上不是SQL Server的正确扩展名。 I tried to rename it to .mdf, but no luck. 我试图将其重命名为.mdf,但没有运气。

What should I do? 我该怎么办? The client is out for vacation on some island and cannot be contacted at the moment? 客户正在某个岛上度假,现在无法联系吗?

This is backup file, you need to restore database from backup. 这是备份文件,您需要从备份还原数据库。

How to: Restore a Database Backup (SQL Server Management Studio) 如何:还原数据库备份(SQL Server Management Studio)

This is SQL Server backup database file. 这是SQL Server备份数据库文件。 You can restore it by following these steps: http://msdn.microsoft.com/en-us/library/ms177429.aspx 您可以按照以下步骤还原它: http : //msdn.microsoft.com/zh-cn/library/ms177429.aspx

Alex Aza has the right answer. 亚历克斯·阿扎(Alex Aza)有正确的答案。 But remember to create users for the database, before you restore the provided .bak file. 但是,请记住在还原提供的.bak文件之前为数据库创建用户。 A backup file only hold a user id -- the complete user definition is held in the server instance. 备份文件仅包含一个用户ID-完整的用户定义保存在服务器实例中。 Thus, it is better to create the users needed before restoring a backup from another server instance which is the case in your project. 因此,最好在从另一个服务器实例还原备份之前创建所需的用户,这在您的项目中就是这种情况。

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

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