SQL Server backup and restore system database

Source: Internet
Author: User
Tags microsoft sql server mixed

A system database is a necessary database for managing and maintaining SQL Server, which is critical to the operation of the server instance. Multiple system databases must be backed up after a large number of updates, including master, model, msdb, and backup of these system databases to restore and restore the SQL Server system in the event of a system failure, such as a hard drive loss


system databases that need to be backed up



1. Backing Up the system database


2. Simulating database corruption

(1) First, stop the SQL Server service


(2) Then, delete the system database file

(3) Turn on SQL Server service again, find the system error, SQL Server database system is paralyzed


3. Start rebuilding the database now

(1) First, locate the installation command C:\Program Files\Microsoft SQL Server\100\setup Bootstrap\release\setup.exe and copy four rows to the C drive


(2) Enter the character interface to locate and execute the installation command

In the case of Windows Authentication mode, the following syntax is required:

setup/action=rebuilddatabase/quiet/instancename=< DB instance name >/sqlsysadminaccounts=< login name;?

In the case of mixed authentication mode, you also need to use the/SAPWD parameter to provide the SA password with the following syntax:

setup/action=rebuilddatabase/quiet/instancename=< DB instance name >/sqlsysadminaccounts=< login >/sapwd=<sa Password >

My database is mixed authentication mode, so enter the following command:


4. Restart the service now, open the database and discover that the database is initialized, so you need to restore the master database

(1) Single-user mode enable SQL Server service

Netstart mssqlserver/m/S


(2) Credit to connect to SQL Server instance

SQLCMD-E-S ServerName


(3) After connecting, restore the master database

Restore Database Master from disk= ' master backup file path '

Go


5. Start the service now, open the database, and find that the database is back to normal


6. Restore the msdb database


7. Restore the Model database



SQL Server backup and restore system database

Related Article

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.