mad*_*koy 5 sql-server sql-server-2008-r2
My database suddenly stopped working and from checking the error logs it says that the master database was corrupted.
So I tried rebuilding the system database with the command:
setup /ACTION=REBUILDDATABASE /QUIET
/INSTANCENAME=<instance name> /SQLSYSADMINACCOUNTS=<accounts>
Run Code Online (Sandbox Code Playgroud)
After running the command, the database server has started working again, but all my database are nowhere to be found. I really need some ideas as to I have no backup databases.
I have the idea that the database files (mdf, ldf, ndf) are still on my local drive so is it possible to relink those files to a database?
update
I tried creating a database with the same name on the instance and got the error
Create failed for Database 'db'. (Microsoft.SqlServer.Smo)
Cannot create file 'D:\Program Files\Microsoft SQL Server\MSSQL10_50.db\MSSQL\DATA\db.mdf' because it already exists. Change the file path or the file name, and retry the operation.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 5170)
Run Code Online (Sandbox Code Playgroud)
这证明了我的想法,文件仍然存在。那么如何将其重建/恢复到我的数据库?
您可以尝试使用文件附加丢失的数据库。您可以右键单击 Management Studio 中的数据库文件夹并选择“附加”。
另一种选择,也是我通常会选择的选择,是使用您拥有的任何备份。但是,您会遇到一些数据丢失。如果您对数据库使用完整恢复模式,您应该能够恢复到上次事务日志备份。否则,如果您使用简单恢复模式,则只能从最新的完整备份进行恢复。
归档时间: |
|
查看次数: |
7041 次 |
最近记录: |