INF: Hey, my SQL Server Service is not starting – what do I do?
This is one of those challenging situations when customers call us at times. I can understand the gravity of the situation – your boss is behind your back, your business is down, your application is down, your website cannot accept orders or your phone is ringing off the hook with calls from the helpdesk. Don’t worry; I will guide you through some basic steps & actions that you can take to make some sense amidst all this madness.
Nothing in life is to be feared. It is only to be understood. - Marie Curie ******
Have you ever called SQL CSS for a startup issue and seen the engineer use some cool trace flags or parameters to get SQL started? Well, it’s all documented (well, most of it that’s worth knowing)
**Using the SQL Server Service Startup Options
The most common ones by far that I use on SQL startup issues are**:-**
Start as a console application, not as a service.
Tries to start the SQL service in single user mode, i.e. only a single user can connect. This single user connection can be either a sysadmin or a regular user connection
Tries to start the SQL service in Minimal configuration mode. This implicitly puts SQL Server in single-user mode and this also means only the system databases master, model, tempdb & mssqlsystemresource are recovered and started.
Tries to start the SQL Server should be started with the specified trace flag which follows after -T. Again this is case sensitive.
Specifies the number of megabytes (MB) of memory that SQL Server leaves available for memory allocations within the SQL Server process, but outside the SQL Server buffer pool. The default value for this is 256MB.
You can limit the connections to the specified client application. For example, -m"SQLCMD" limits connections to a single connection and that connection must identify itself as the SQLCMD client program. You can use this option when you are starting SQL Server in single-user mode and an unknown client application is taking the only available connection. Cool option J
Limits the number of checkpoint I/O requests per second to the value specified e.g. 123 MB/sec. Refer https://support.microsoft.com/kb/929240for more info.
For more information some common trace flags see here https://msdn.microsoft.com/en-us/library/ms188396.aspx. Few of the common ones that come handy during startup issues are:
- 3608 à Starts SQL and recovers only the master database.
- 4010 à Allows only shared memory connections to the SQL Server. Meaning, you will only be able to connect from the server machine itself. Client connections over TCP/IP or named pipes will not happen.
- 4606 à Disables password policy check during server startup.
- 4022 à Skips launching automatic stored procedures when SQL Server starts. This is equivalent to setting "scan for startup procs" configuration option to 0.
Here are the steps to start SQL Server from command prompt:-
****Right-click on the SQL Server service name in services.msc
Copy the path that you see here.
Open a Command Prompt window and navigate to the path from step2. ****
E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn>sqlservr.exe -c -m -sSQL2005 ** **
A common mistake that people sometime make is to try and start SQL using sqlservr.exe and you get this error,
Text: “Your SQL Server installation is either corrupt or has been tampered with. Please uninstall then re-run setup to correct this problem”
Okay, you see this message and you are thinking **oh no, there goes my dinner plans!
**The above message can be misleading at times. You will get the above error if you try to start SQL server from command prompt for a named instance and do not specify an instance name. Without the -s switch the default instance will try to start, but using the sqlservr.exe file from another instance binn folder. You will also get this error if you specify an invalid parameter to sqlservr.exe. So, the installation is not corrupt after all (Dinner plans back on?)
Here’s how to start a named instance,
sqlservr.exe -c -s INSTNAME
Here’s how to start a default instance,
**Here’s how to start a named instance recovering only master database
**sqlservr.exe -c -sMATRIX –T3608
Some Common Scenarios for Startup Failures
Windows could not start the SQL Server (MSSQLSERVER) on Local Computer. For more information, review the System Event Log.
“The service failed to respond in a timely fashion”.
“The service failed to start”.
- Locate the SQL Errorlog as that is the 1st place to look if a SQL service is not starting.
- This can be done by looking up the -e startup parameter value for the SQL Server instance in question.
- Verify that the files pointed to by -d (master data file location), -e (Errorlog location) and -l (master log file location) actually exist and have the correct file paths and that the SQL service startup account has proper permissions.
Alternately you can also get this from the registry by looking at the values SQLArg0, SQLArg1 and SQLArg2 in the following locations.
Named: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\INSTANCENAME\MSSQLServer\Parameters
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\Parameters
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQLServer\Parameters
4. Once you have located the errorlog open it in notepad and look for any errors. An example would be like this,
2010-11-20 07:50:58.250 Server Error: 17113, Severity: 16, State: 1.
2010-11-20 07:50:58.250 Server Error 2(The system cannot find the file specified.) occurred while opening file ‘C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\master.mdf’ to obtain configuration information at startup. An invalid startup option might have caused the error. Verify your startup options, and correct or remove them if necessary.
The above message clearly indicates that the master.mdf was not found in the location it was expecting it to be found.
You can also look into the Windows Application log for any events related to SQL Server.
initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG1\ERRORLOG'. Operating system error = 3(error not found).
The above error indicates that SQL could not find the errorlog file in the above location. What does this mean? This means that since SQL could not find the errorlog it has no place to log messages, hence it did not start.
When you are faced with this error, then if you look into the errorlog location, you will notice log files whose date/time stamp is not current. Do not make the mistake of opening these files and troubleshooting based on messages that are not for the current startup failure. This is where looking into the application log gives you the current entries.
I hope cleared up any confusion you might have had regarding this rule, the warning status and the simple logic behind the rule. As always stay tuned for more SQL tips…
2011-04-16 07:52:49.32 spid5s Error: 17204, Severity: 16, State: 1.
2011-04-16 07:52:49.32 spid5s FCB::Open failed: Could not open file C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf for file number 2. OS error: 32(error not found).
OS Error 32 translates to “The process cannot access the file because it is being used by another process.” How did I know this? Simple. You can find the text for any windows error by running this from a command prompt à net helpmsg XXX, where XXX is the error number
In the above scenario, some other process/application has a lock on master.mdf and this isn’t allowing SQL to take access, hence the service fails to start. To find out which process it is you can use either Process Explorer or Handle.exe from sysinternals. The usual culprits are Anti-Virus or Anti-Malware services. Once you identify the process, after stopping that, attempt to start SQL again. If it fails, verify from the errorlog that the error code is still 32 and has not changed. Most people miss this trick and assume the error is the same after making some changes. Don’t take it for granted, since the error might have changed but the service still doesn’t start. This indicates that the changes done have been successful.
Some Common Causes for SQL Service startup failures
- Access denied on the folders for the SQL Server Service Account, specifically on the DATA folder which contains the SQL Server system databases.
- Due to some other processes like anti-virus holding a lock on the SQL database files.
- Insufficient permissions granted to the SQL Server Service account.
- Server side protocols for SQL not set correctly or disabled.
- Critical system database files not found due to either accidental deletion of files or disk failures.
- System database files having inconsistencies preventing SQL Server startup.
- Password of the service account was changed but not updated on the server that has the SQL instance installed.
- Startup parameters have incorrect file path locations.
- The SQL Server service is disabled in Service Control Manager.
**Error Messages of SQL Server 2005 Start Up Failure
An error occurred during encryption
SQL Server Support Team