星空网 > 软件开发 > 数据库

backup3:master 数据库的备份和还原

SQL Server 中,master 数据库记录系统级别的元数据,例如,logon accounts, endpoints, linked servers, and system configuration settings,同时,master 数据库记录其他数据库及其文件的位置,因此,在启动SQL Server实例时,master数据库必须最先启动。master 数据库是如此重要,必须频繁地备份master数据库。Only full database backups of master can be created.

一,备份master数据库

master数据库只能做full backup,不能做差异备份和事务日志备份,原因是master只能处于Recovered 状态,不能处于NoRecovery(recovering)状态。

backup database [master]to disk = 'D:\TestDBBackupFolder\master_1.bak' --specify new backup filewithcompression,format,init,skip,stats=5

二,还原master数据库

在还原master数据之前,首先,必须停止SQL Server的所有服务(Service),包括MSSQLServer、Agent、Broser、Fulltext等,然后,以管理员打开命令行;

step1,使用命令行net start,以single user 模式启动SQL Server实例的Service:MSSQLServer

参数/m“sqlcmd”:表示以单用户(Single User)模式启动Service,并且,只允许sqlcmd客户端访问service;

net start MSSQLSERVER /m"sqlcmd"

step2,使用sqlcmd登录到SQL Server实例

-E:表示以信任连接(trusted connection)方式登录Service,参数-E是默认的;

-S:表示sqlcmd连接的Server-Name

sqlcmd -E -S server-name

step3,使用sqlcmd还原master数据库,指定replace选项,将原有的master数据库替换

restore database masterfrom disk='D:\DBBackup\master.bak'with replace;go

master数据还原完成之后,启动SQL Server实例的Service,就可以正常访问SQL Server实例。

 

参考文档:

SqlServer系统数据库还原(三)系统数据库master-msdb-model 还原模拟测试

master Database

Restore the master Database (Transact-SQL)

 

Start SQL Server in Single-User Mode

 

sqlcmd Utility

Use the sqlcmd Utility




原标题:backup3:master 数据库的备份和还原

关键词:数据库

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

香港公司注册代办流程:https://www.ikjzd.com/articles/151201
江苏专业注册香港公司流程:https://www.ikjzd.com/articles/151202
香港公司会计注册的流程:https://www.ikjzd.com/articles/151203
在香港注册有限公司流程图:https://www.ikjzd.com/articles/151204
敲重点!Facebook广告总被拒?这些雷区来看看你中招了没?:https://www.ikjzd.com/articles/151205
船期延误!MAERSK EMDEN在赤湾码头锚泊,船上发现疑似病例:https://www.ikjzd.com/articles/151207
皇家游轮航线 皇家邮轮旅游攻略:https://www.vstour.cn/a/408245.html
2017春节旅游攻略有吗:https://www.vstour.cn/a/408246.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流