Here we will see how to restart MsSQL server on Linux machine.

How to restart MsSQL server on Linux:

MsSQL is a very commonly used database server, at times due to the many reasons you may need to stop/start/restart the server and even look for the status whether it is running or not?

Let’s see how to accomplish these tasks on a Linux machine.

Get Status of MsSQL:

We can get the status of MsSQL server using systemctl command. systemctl command is used to examine and control the state of “systemd” system and service manager.

$systemctl status mssql-server

systemctl status mssql-server
● mssql-server.service - Microsoft SQL Server Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-03-31 12:55:05 BST; 1 weeks 0 days ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 212021 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ├─212021 /opt/mssql/bin/sqlservr
           └─212043 /opt/mssql/bin/sqlservr

As you can on the above output, the Microsoft SQL Server is running on my Linux machine. Let’s restart the running MsSQL server now.

Stop MsSQL Server:

To stop/start the MsSQL server you need sudo access. Let’s run the below systemctl command with sudo to stop the MsSQL server.

#Stop mssql server
$sudo systemctl stop mssql-server

Start MsSQL Server:

#Start mssql server
$sudo systemctl Start mssql-server

You won’t see any success messages by running the above commands, that means your server has started successfully, you can confirm the status by using systemctl status mssql-server command as we have seen earlier.

Restart MsSQL Server:

Instead of stop and start, we can even restart the server directly using restart command like below.

# Restart mssql server
$sudo systemctl restart mssql-server

Happy Learning 🙂