How to restore Master DB in SQL 2005?

I've tried starting SQL from the command line in single user mode (-m). When I try to open Management Studio I receive an error that it can't connect. Can you only restore master from a command line in SQL 2005? Or can I do it from a GUI?

Thanks,
Mark

[260 byte] By [winsyss] at [2008-2-18]
# 1
OK, I now tried starting the SQL Server Service form the 'Services' GUI in Windows, using the parameters -c and -m. Now I am able to open Management Studio. When I right-click on the master database and choose 'Tasks-Restore-Database' master is not in the list of databases to restore.
I tried typing it in manually, but the restore failed.
winsyss at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Disaster Recovery and Availability...
# 2

You need to first start SQL Server in single user mode (or put it in single user mode), and then restore your database. So using -m should work if you can get in via Management Studio (assuming no one else gets in before you).

Have you also tried using T-SQL's RESTORE DATABASE command?

AllanHirt at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Disaster Recovery and Availability...
# 3

Thanks for the reply Allan.

How do suggest I start SQL in single user mode.

I tried running the sqlsrvr.exe with the /m switch from the command line, but then Management Studio wouldn't connect.

I then tried starting the sqlserver service from the windows services gui, using the /m parameter, but then in Management Studio "Master" wasn't in the list of databases that I could choose from when I selected the 'restore' task. I tried typing 'master' in the selection box and then ran the restore, but it failed.

Any ideas?

winsyss at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Disaster Recovery and Availability...
# 4

I would use the command

NET START "MSSQLSERVER" /m

Connect with either SQLCMD or management studio, and use the TSQL command:

USE master

GO

RESTORE DATABASE master

FROM TAPE = '\\.\Tape0'

GOObviously substituting your backup device/file as appropriate. See Books Online for specifics.

KevinFarlee at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Disaster Recovery and Availability...
# 5

Unfortunately the NET START "MSSQLSERVER" /m command does not work for me.

However, I can add "-m" to the Startup parameters in the SQL Server service from the Services GUI and it starts in single-user mode. I was having trouble connecting to a query window in Management Studio, when it hit me that there were still other SQL Services running. I think that one of the other services was getting to the one connection that was available before I could open a query.

So I stopped ALL SQL related services, started in "-m" single user mode, and was able to open a query and restore the master database.

It's always the little things.

csi_hugh at 2007-8-30 > top of Msdn Tech,SQL Server,SQL Server Disaster Recovery and Availability...

SQL Server

Site Classified