SQL Recovery master database method only the MDF file's database is restored _mssql

Source: Internet
Author: User
Tags microsoft sql server mssql mssqlserver

First, let's talk about SQL Server recovery master database method, as follows

The first step: copy model.mdf, Mastlog.ldf, Model.mdf, Modellog.ldf, msdbdata.mdf, msdblog.ldf files.
From X:\Program Files\Microsoft SQL Server\mssql10. Mssqlserver\mssql\binn\templates
To X:\Program Files\Microsoft SQL Server\mssql10. Mssqlserver\mssql\data
Note: the above "X:\Program Files\Microsoft SQL Server" is the installation directory for SQL Server. The following "C:\Program Files\Microsoft SQL Server" is a directory under the system disk

Step Two: Locate and execute the installation command
1. First find the installation command: C:\Program Files\Microsoft SQL Server\100\setup Bootstrap\release\setup.exe
2. Executive Order

If you are just Windows Authentication mode, you need only the following syntax:

Copy Code code as follows:
Setup/action=rebuilddatabase/quiet/instancename=<instance name>/sqlsysadminaccounts=<accounts>

If this is a composite authentication mode, you will need to provide the SA password using the/sapwd parameter:

Copy Code code as follows:
Setup/action=rebuilddatabase/quiet/instancename=<instance name>/sqlsysadminaccounts=<accounts>/ Sapwd=<sa password>

I installed the composite authentication mode, the SQL Server system administrator account is the Administrators group, the SA password is 123456. And on a default instance: MSSQLServer.
So at the command line, execute the following command:

Copy Code code as follows:
setup/action=rebuilddatabase/quiet/instancename=mssqlserver/sqlsysadminaccounts=administrators/sapwd=123456

Step three: do not have any prompt information (whether successful or not) after execution, but you can immediately C:\Program Files\Microsoft SQL Server\100\setup Bootstrap\log\ View the installation log in Summary.txt.

Finally, the SQL Server service was successfully started in SQL Server Configuration Manager.

This situation occurs during processing what about SQL recovery database? How to recover when only MDF files are restored, that is, the database with log files

SQL Recovery Database Concrete implementation steps:

1, create a new database with the same name.

2, stop the database service, overwriting the new database master file (tips: Best place in the same disk, the new database main file deleted or removed, and then the database to restore the main file to cut the past, so you can save time. )

3, start the database service, the database becomes suspect or suspicious state. Then run in Query Analyzer:
ALTER DATABASE name set emergency with no log files
Set to a state of emergency.

4, and then run:
ALTER DATABASE name set Single_user with no log files
Or:
sp_dboption ' database name without log file ', ' Single user ', ' true '
Set to single user mode.

5, check and rebuild the log file, run:
DBCC CHECKDB (' database name without log file ', Repair_allow_data_loss)
It's a long time. Wait patiently! If you have an error prompt, run again:
DBCC CHECKDB (' database name without log file ', Repair_rebuild)
Be repaired. If there are no errors, you can skip them.

6. Revert to Multi-User mode
ALTER DATABASE name set Multi_user with no log files
Or:
sp_dboption ' database name without log file ', ' Single user ', ' false '
Refresh the database and you can see the database that has been repaired.

The above is for you to share the SQL Recovery database method, I hope to restore the database to help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.