rebulding msdb in sql server 2005
TRANSCRIPT
-
8/13/2019 Rebulding MSDB in SQL Server 2005
1/4
-
8/13/2019 Rebulding MSDB in SQL Server 2005
2/4
3. Click on the Advancedtab. Under Startup Parametersyou will be adding the followingparameters to the beginning of the string: -m;-c;-T3608;
Npr. Kod CL3TSQL:
-m;-c;-T3608;-dM:\MSSQL10_50.CL3TSQL\MSSQL\DATA\master.mdf;-eM:\MSSQL10_50.CL3TSQL\MSSQL\Log\ERRORLOG;-lM:\MSSQL10_50.CL3TSQL\MSSQL\DATA\mastlog.ldf
2. Restart SQL Server3. Connect to SQL server through the Management Console. From this point on we will be using TSQL
to issue the commands so click the New Querybutton on the top left. At this point you should be in
the master database inside the query window.
4. Detach the MSDB database using the following commands:use master
go
sp_detach_db msdb
go
and click Execute
5. We need to move (or rename, I prefer moving them) the existing MDF and LDF files for the MSDBdatabase so that we can recreate it.
1. Usually these files are located in the following directory:C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
Yours might differ.
2. Move (or rename) the MSDBDATA.mdf and MSDBLOG.ldffiles.6. Back to the Management Studio. Open up the instmsdb.sqlfile in a new query window. This file is
usually located in the following directory:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Install
http://rip747.files.wordpress.com/2008/05/step_3_startup_parameters.jpg -
8/13/2019 Rebulding MSDB in SQL Server 2005
3/4
7. Execute the file. If you see any errors about xp_cmdshell, just ignore them. They are common andthe script will take care of it.
8. At this point you should have your MSDB database restored. The only thing left is cleanup.9. Execute the following command to make sure that xp_cmdshell is once again set to disable for
security reasons:
EXEC sp_configure show advanced options, 1
GO
RECONFIGURE WITH OVERRIDEGO
EXEC sp_configure xp_cmdshell, 0
GO
RECONFIGURE WITH OVERRIDE
GO
10.Shutdown SQL Server11.Go back into your Startup Paremeters for your server in the SQL Server Configuration Manager and
removed the -c;-m;-T3608parameters we added earlier.
12.Restart SQL ServerEverything should be cool at this point and youll be able to recreate any Maintenance Plans and Jobs.
Let me know if you have a better way or a way to restore the configuration information from the old msdb
database.
--
Recreate Corrupt MSDB database
If your msdb goes suspect then you have two choices, restore it from a backup or recreate it (and then
recreate any scheduled jobs).Obviously everyone has a comprehensive and valid set of backups, right? If
only...
Of course, the very first thing you do is work out why it went suspect in the first place and take any
necessary steps to stop it happening again.
Now you'd hope that if you don't have a valid msdb backup then you can at least run repair on it and so
you don't lose everything in there. Well, that works as long as the transaction log isn't damaged. Ok, but
then surely we can stick the database into the now-documented emergency mode (alter database dbname
set emergency) and run emergency mode repair? (dbcc checkdb (dbname, repair_allow_data_loss) in
emergency mode). Nope, msdb can't be put into emergency mode.
So, you're out of options and you're going to have to recreate msdb. Here's what to do (change the
directory paths to suit your installation):
Detach the damaged msdb. You can't just detach msdb because you're not allowed to detach system
databases. However, you can if you start the server with trace flag 3608. I did this by shutting down the
server, navigating to the directory 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn' and
doing the following: start sqlservr.exe -c -T3608
Move or rename the damaged msdb files (msdbdata.mdf and msdblog.ldf in the 'C:\ProgramFiles\Microsoft SQL Server\MSSQL.1\MSSQL\Data' directory)
http://sqlplanet.blogspot.com/2008/07/recreate-corrupt-msdb-database.htmlhttp://sqlplanet.blogspot.com/2008/07/recreate-corrupt-msdb-database.htmlhttp://sqlplanet.blogspot.com/2008/07/recreate-corrupt-msdb-database.html -
8/13/2019 Rebulding MSDB in SQL Server 2005
4/4
Run the instmsdb.sqlscript in the 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Install'
directory
Shutdown and restart the server without the 3608 trace flag (and then recreate any scheduled jobs).
This works on SQL Server 2000 as well.