Five Different Methods To Start, Stop, And Restart SQL Server Services

Total: 3 Average: 4.3

When we install the SQL Server, it also installs the following services:

  1. SQL Server database engine service to manage and access data in SQL Server.
  2. SQL Server Integration Service for the ETL process – we install it when including Integration services during setup.
  3. SQL Server Reporting Service to manage the SQL Server reports.
  4. The SQL Server Agent Service. Note that it is not available in the SQL Server Express edition.

In this article, we are going to learn the following methods to manage SQL Server services:

  1. Start, stop, and restart SQL Server services using the SQL Server configuration manager.
  2. Start, stop, and restart SQL Server services using Services MMC (Microsoft Management Console).
  3. Start, stop, and restart SQL Server services using the PowerShell script.
  4. Start, stop, and restart SQL Server services in Ubuntu Linux.
  5. Start, stop, and restart SQL Server services using the Windows server failover cluster manager.

Let us examine all these methods.

SQL Server Configuration Manager

SQL Server Configuration Manager is a tool for SQL Server services managing, included in the SQL Server software package. When we install SQL Server, this manager gets installed automatically.

To manage the services, launch the SQL Server configuration manager and Right-click on MSSQLSERVER. In a dialog box, you will see the options to start, stop, and restart the services.

Picture 1. Using SQL Server Configuration Manager to manage SQL Server services
Picture 1. Using SQL Server Configuration Manager to manage SQL Server services

If the process timeout or any other error occurs, it informs the user about the problems:

Picture 2. A warning box produced by the SQL Server Configuration Manager
Picture 2. A warning box produced by the SQL Server Configuration Manager

Error details are available in Event Viewer or ErrorLog of the SQL Server.

You can use SQL Server Management Studio can restart services.

Launch SSMS -> Connect to the SQL Server instance -> Right-click on Hostname.

It opens a context menu with the start, stop, pause, and restart options:

Picture 3. Managing SQL Server services with SSMS
Picture 3. Managing SQL Server services with SSMS

Services MMC (Microsoft Management Console)

To manage SQL Server settings with Services MMC (Microsoft Management Console), do the following:

Open Control Panel -> Administrative tools -> Click on Services -> Find MSSQLSERVER -> Right-click on it.

In a dialog box that opens after right-clicking, you get the options to start, stop, and restart the services:

Picture 4. Managing options in Services MMC
Picture 4. Managing options in Services MMC

Alternatively, you can run the Services.msc command to open Services MMC.

PowerShell Commands

To start and stop any service, use Start-Service and Stop-Service command.

Launch PowerShell and execute the following command to start the services:

PS C:\WINDOWS\system32> Start-Service MSSQLSERVER

To view the SQL Server service status, open SQL Server Configuration Manager and click on SQL Server Service:

Picture 5. The result of executing the Start-Service PowerShell command
Picture 5. The result of executing the Start-Service PowerShell command

The following command stops the service:

PS C:\WINDOWS\system32> Stop-Service -Force MSSQLSERVER
Picture 5. The result of executing the Stop-Service PowerShell command
Picture 5. The result of executing the Stop-Service PowerShell command

Finally, the command to restart the SQL Server service is as follows:

PS C:\WINDOWS\system32> Restart-Service -Force MSSQLSERVER

Manage services in Ubuntu Linux

In Ubuntu Linux, we must use the systemctl command to manage SQL Server service. It is a Linux command for controlling the service manager and systemd system.

To illustrate this option, I have installed SQL Server 2019 on Ubuntu Linux. Note: The root user must be used to manage the services. If you log in as a different user, execute the following command in the terminal:

nisarg@LinuxSQL01:~$ sudo -i

Run the below command to stop the service:

root@LinuxSQL01:~# systemctl stop mssql-server.service
Picture 6. The stop command execution on Linux
Picture 6. The stop command execution on Linux

We do not receive any feedback on the terminal to verify the service status. Thus, to check it, run the command:

root@LinuxSQL01:~# systemctl status mssql-server. service
Picture 7. Checking the service status on Linux
Picture 7. Checking the service status on Linux

The following command starts the SQL Services:

root@LinuxSQL01:~# systemctl start mssql-server.service
Picture 8. Execution of the start services command on Linux
Picture 8. Execution of the start services command on Linux

To view the status, run the below command:

root@LinuxSQL01:~# systemctl status mssql-server.service
Picture 9. View the SQL Server services status on Linux
Picture 9. View the SQL Server services status on Linux

The following command is used to restart the service:

root@LinuxSQL01:~# systemctl restart mssql-server.service
Picture 10. Restart the SQL Server services on Linux
Picture 10. Restart the SQL Server services on Linux

The Windows Server failover cluster manager

Managing SQL Server services on the stand-alone instance and in the failover cluster environment is different. We can use any of the above methods, but, according to Microsoft’s best practices, we should use the Windows Failover Cluster Manager.

When we install an SQL Server on a clustered environment, an SQL Server role is created. We can view this role:

Open the Failover Cluster Manager -> Click on Roles -> Right-click on the MSSQLSERVER role.

A context menu opens. Hover on Move and select Best Possible Node:

Picture 11. Viewing the SQL Server role and moving resources in the failover cluster environment
Picture 11. Viewing the SQL Server role and moving resources in the failover cluster environment

Once resources are moved to the secondary node, open the SQL Server Configuration Manager to verify that the service has been stopped on SQL01 Node. As you can see, it’s done correctly:

Picture 12. Confirming that the service has been stopped
Picture 12. Confirming that the service has been stopped

Summary

This article presented five different methods to manage SQL Server services using different means and in different environments. 

Nisarg Upadhyay

Nisarg Upadhyay

Nisarg is a SQL Server Database Administrator and Microsoft certified professional who has more than 5 years of experience with SQL Server administration and 2 years with Oracle 10g database administration. He has expertise in database design, performance tuning, backup and recovery, HA and DR setup, database migrations and upgrades. He has completed the Bachelors in Information Technology from Ganpat University.