Sql-server – SQL Server 2008 service keeps crashing

sql serversql-server-2008startup

Problem

I have a Windows 7 Ultimate x64 machine running SQL Server 2008 SP3. After creating a local database, when trying to start the service it keeps stopping (crashing).

Research

I read a lot of material online, disabled Windows and Java updates that might cause conflicts, and shut down the SQL Server service on the local machine in order to find out if it was the problem – but it didn't help.

Went over to the Event Viewer and received the following logs:

Cannot create file 'c:\Program Files (x86)\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\temp_MS_AgentSigningCertificate_database.mdf' because it already exists. Change the file path or the file name, and retry the operation.

Script level upgrade for database 'master' failed because upgrade step 'sqlagent100_msdb_upgrade.sql' encountered error 598, state 1, severity 25. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.

SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.

Question

I don't really understand what is the temp_MS_AgentSigningCertificate_database.mdf file and is SQL Server trying to upgrade/update itself?

How do I resolve this issue?

Additional information

This is the first installation on a fresh operating system, so it couldn't be from any previous installation attempt. I should use the latest SQL Server version, which is much much better (I'm already using it for other purposes), but this one is used as a part of my learning of penetration testing. I need to launch this specific version. I don't think a reinstall would solve my problem in that case.

I really don't have anything on this database yet; I just finished installing it. It is the first install on a fresh operating system (Windows 7 Enterprise x64 on a VMware virtual machine, but that shouldn't really matter).

The book I am reading is https://www.nostarch.com/pentesting. It was published in 2014, so it is considered to be up-to-date, yet still explicitly requires to install SQL Server 2008 as it has known vulnerabilities that we can exploit as a part of the learning process.

Best Answer

As suggested by Aaron Bertrand, renaming the files was just enough to solve this problem:

Save your backup files (or mdf/ldf files if you don't bother taking backups), and then obliterate that instance. Install a new instance (preferably of a newer version) and then restore/attach your databases to the new instance.

Try renaming that mdf file it's complaining about (and probably the corresponding ldf file, too). I haven't seen this issue before but it may take some trial and error for such an ancient, out-of-support version. Does your pen testing thing mention SQL Server 2008 (which could just indicate when it was written), or explicitly require it? Seems odd to require a version that is FIVE major versions ago, no longer supported, and quickly declining in use. I would double check that you even need to be dealing with this.