Check & Restart SQL Server Services on Linux

As of the 2017 Edition of SQL Server we have been able to install SQL Server on Linux. Linux will likely be more of an unfamiliar environment for traditional Microsoft SQL DBAs. This guide will walk you through how to check the status of SQL Server services and manage them (start, stop, restart) on a Linux host.

Microsoft provides official documentation here: Start, stop, and restart SQL Server services on Linux

Most Linux distributions, including CentOS, Ubuntu, Debian, and RedHat, use systemctl for service management. However, note that systemctl may not be available on all Linux environments, such as WSL (Windows Subsystem for Linux), which doesn’t use the systemd init system.

This guide will demonstrate key commands for managing SQL Server services using systemctl.

The following is included below:
> 1. Showing Enabled Services on Linux
> 2. Check Status of SQL Server Service Linux
> 3. Stop, Start and Restart SQL Server Services on Linux

1. Showing Enabled Services on Linux

To list all enabled services, including those that automatically start at system boot, run:

systemctl list-unit-files | grep enabled
systemctl list unit files enabled

If mssql-server is not listed, it won’t start automatically after a reboot. To enable it, use:

sudo systemctl enable mssql-server

2. Check Status of SQL Server Service on Linux

To check the current status of the SQL Server service:

sudo systemctl status mssql-server
systemctl SQL Server Status

If the SQL Service is active, the output of the command will include the text “active (running)” in green. This indicates that the service is currently running and is available to process requests.

If the service is not active, the output will include the text “inactive (dead)” in red. This indicates that the service is not currently running, and may need to be started or restarted in order to be used.

3. Stop, Start or Restart the SQL Server Services on Linux

Stop SQL Service on Linux:

sudo systemctl stop mssql-server

Start SQL Service on Linux:

sudo systemctl start mssql-server

Restart SQL Service on Linux:

sudo systemctl restart mssql-server
systemctl Restart SQL Server

After running any of these commands, it’s recommended to verify the service status to confirm the desired action was successful:

sudo systemctl status mssql-server