SQL Server 2008 master與msdb數(shù)據(jù)庫(kù)的備份與恢復(fù)
sql server 2005 & 2008 master與msdb數(shù)據(jù)庫(kù)的備份與恢復(fù),master與msdb數(shù)據(jù)庫(kù)的備份與普通數(shù)據(jù)庫(kù)一樣,本文主要描述master與msdb數(shù)據(jù)庫(kù)的恢復(fù)的一些個(gè)人積累。
恢復(fù)master與msdb數(shù)據(jù)庫(kù)關(guān)鍵在于以單用戶模式啟動(dòng),其它并沒(méi)有太大的區(qū)別。
由于系統(tǒng)數(shù)據(jù)庫(kù)對(duì)Sql Server來(lái)說(shuō)尤其重要,為了確保SQL SERVER系統(tǒng)的正常運(yùn)行,除了日常備份用戶的數(shù)據(jù)庫(kù)之外,我們還需要備份系統(tǒng)數(shù)據(jù)庫(kù),如對(duì)Master,Model,Msdb(TempDB不需備份)進(jìn)行完整備份
1、還原Master數(shù)據(jù)庫(kù)
如果系統(tǒng)配置丟失或Master出現(xiàn)問(wèn)題,可以進(jìn)入單用戶模式進(jìn)行還原;如果出現(xiàn)下列情況,必須重新生成損壞的 master 數(shù)據(jù)庫(kù):
A. master 數(shù)據(jù)庫(kù)的當(dāng)前備份不可用。
B. 存在 master 數(shù)據(jù)庫(kù)備份,但由于 Microsoft SQL Server 實(shí)例無(wú)法啟動(dòng),因此無(wú)法還原該備份。
1、重新生成 master 數(shù)據(jù)庫(kù):
注意:
在 SQL Server 2005 中已廢止 Rebuildm.exe 程序。若要重新生成 master 數(shù)據(jù)庫(kù),請(qǐng)使用 setup.exe。
1、 Start /wait setup.exe /qn INSTANCENAME=<InstanceName> REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=<NewStrongPassword>
例:start /wait e:“setup.exe /qn INSTANCENAME=mssqlserver REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=abc123@!@
注:INSTANCENAME:指定實(shí)例名,默認(rèn)實(shí)例則用mssqlserver表示
REINSTALL:指定引擎
SAPWD:強(qiáng)密碼
Setup.exe:指定光盤(pán)1中的根目錄下的文件
/qn 開(kāi)關(guān)用于取消所有安裝程序?qū)υ捒蚝湾e(cuò)誤消息。如果指定 /qn 開(kāi)關(guān),則所有安裝程序消息(包括錯(cuò)誤消息)都將寫(xiě)入安裝程序日志文件。有關(guān)日志文件的詳細(xì)信息,請(qǐng)參閱如何查看 SQL Server 2005 安裝日志文件。
指定 /qb 開(kāi)關(guān)將顯示基本的安裝程序?qū)υ捒?。還會(huì)顯示錯(cuò)誤消息。
2、 還原Master備份(在恢復(fù)master的備份時(shí)要注意:必須在單用戶(single user)模式下進(jìn)行 ) a.進(jìn)入單用戶模式的方法:
1.在命令行模式下輸入sqlservr -c -f -m或者輸入sqlservr -m
其中:-c 可以縮短啟動(dòng)時(shí)間,SQL Server 不作為Windows NT的服務(wù)啟動(dòng)
-f 用最小配置啟動(dòng)SQL Server
-m 單用戶模式啟動(dòng)SQL Server
2.系統(tǒng)默認(rèn)沒(méi)有設(shè)置PATH,先進(jìn)入CMD,進(jìn)入“C:“Program Files“Microsoft SQL Server“MSSQL.1“MSSQL“Binn”,執(zhí)行SQLSERVR.EXE –M
打開(kāi)SSMS工具,先斷開(kāi)連接,再新建查詢,執(zhí)行以下命名還原
USE master
GO
RESTORE DATABASE master
FROM disk=‘c:“master.bak‘
GO
開(kāi)始實(shí)驗(yàn)了~~~
MASTER重新生成
為了模擬MASTER數(shù)據(jù)庫(kù)壞了,我們就刪除MASTER數(shù)據(jù)庫(kù)(要停止SQL SERVER服務(wù)才能刪除)在我的電腦,C:“ PROGRAM FILES“MICROSOFT SQL SERVER“MSSQL.1“MSSQL“DATE 中刪除MASTER.MDF
重新生成MASTER
1.首先在CMD中輸入
start /wait setup.exe /qn INSTANCENAME=<InstanceName> REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=<NewStrongPassword>
其中的 SETUP.EXE為啟動(dòng)光盤(pán)的路徑,我這里的是 E:“SETUP.EXE /QN
我這里的為默認(rèn)實(shí)例所以其中的<INSTANCENAME>用 MSSQLSERVER代替
最后的<NewStrongPassword>為密碼我設(shè)密碼為abc123@!@,所以就用abc123@!@代替<NewStrongPassword>
若沒(méi)有返回錯(cuò)誤,我們就可以到我的電腦中C:“ PROGRAM FILES“MICROSOFT SQL SERVER“MSSQL.1“DATE上面又有MASTER.MDF了
接下來(lái)進(jìn)入目錄
單用戶模式
啟動(dòng)SSMS工具,新建查詢
輸入命令
啟動(dòng)服務(wù)(MSSQL SERVER)
打開(kāi)SSMS
連接到數(shù)據(jù)庫(kù)后就可以發(fā)現(xiàn)數(shù)據(jù)庫(kù)中的數(shù)據(jù)又回來(lái)了
以下是我在命令行下搞的命令,我用記事本的方式全部復(fù)制下來(lái)了,為了不傳附件,我就直接粘貼到下面了
Microsoft Windows [版本 5.2.3790]
(C) 版權(quán)所有 1985-2003 Microsoft Corp.
C:“Documents and Settings“Administrator>start /wait e:“setup.exe /qn INSTANCENAME=mssqlserver REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=abc123@!@
C:“Documents and Settings“Administrator>cd C:“Program Files“Microsoft SQL Server“MSSQL.1“MSSQL“Binn
C:“Program Files“Microsoft SQL Server“MSSQL.1“MSSQL“Binn>sqlservr.exe -m
2008-04-18 15:47:46.56 Server Authentication mode is MIXED.
2008-04-18 15:47:46.59 Server Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 1)
2008-04-18 15:47:46.59 Server (c) 2005 Microsoft Corporation.
2008-04-18 15:47:46.59 Server All rights reserved.
2008-04-18 15:47:46.59 Server Server process ID is 3984.
2008-04-18 15:47:46.59 Server Logging SQL Server messages in file ‘C:“Program Files“Microsoft SQL Server“MSSQL.1“MSSQL“LOG“ERRORLOG‘.
2008-04-18 15:47:46.59 Server This instance of SQL Server last reported using a process ID of 764 at 2008-4-18 15:46:40 (local) 2008-4-18 7:46:40 (UTC). This is an informational message only; no user action is required.
2008-04-18 15:47:46.60 Server Registry startup parameters:
2008-04-18 15:47:46.60 Server -d C:“Program Files“Microsoft SQL Server“MSSQL.1“MSSQL“DATA“master.mdf
2008-04-18 15:47:46.60 Server -e C:“Program Files“Microsoft SQL Server“MSSQL.1“MSSQL“LOG“ERRORLOG
2008-04-18 15:47:46.60 Server -l C:“Program Files“Microsoft SQL Server“MSSQL.1“MSSQL“DATA“mastlog.ldf
2008-04-18 15:47:46.62 Server Command Line Startup Parameters:
2008-04-18 15:47:46.62 Server -m2008-04-18 15:47:46.64 服務(wù)器 SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2008-04-18 15:47:46.67 服務(wù)器 Detected 1 CPUs. This is an informational message; no user action is required.
2008-04-18 15:47:46.78 服務(wù)器 Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required.
2008-04-18 15:47:46.84 服務(wù)器 Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2008-04-18 15:47:47.95 服務(wù)器 Attempting to recover in-doubt distributed transactions involving Microsoft Distributed Transaction oordinator (MS DTC).
This is an informational message only. No user action is required.
2008-04-18 15:47:47.96 服務(wù)器 Database Mirroring Transport is disabled in the endpoint configuration.
2008-04-18 15:47:47.96 spid5s Warning ******************
2008-04-18 15:47:47.96 spid5s SQL Server started in single-user mode. This an informational message only. No user action is required.
2008-04-18 15:47:47.99 spid5s Starting up database ‘master‘.
2008-04-18 15:47:48.17 spid5s Recovery is writing a checkpoint in database ‘master‘ (1). This is an informational message only. No user action is required.
2008-04-18 15:47:48.28 spid5s SQL Trace ID 1 was started by login "sa".
2008-04-18 15:47:48.32 spid5s Starting up database ssqlsystemresource‘.
2008-04-18 15:47:48.76 spid5s Server name is ‘VM01‘. This is an informational message only. No user action is required.
2008-04-18 15:47:48.78 spid8s Starting up database ‘model‘.
2008-04-18 15:47:49.20 服務(wù)器 A self-generated certificate wa
關(guān)鍵詞:SQL,數(shù)據(jù)庫(kù),備份與恢復(fù)
閱讀本文后您有什么感想? 已有 人給出評(píng)價(jià)!
- 1
- 1
- 1
- 2
- 1
- 1