This article covers the installation and configuration of a Microsoft SQL server instance running on Ubuntu 16.04 LTS. I will be using an Elastic Compute Service (ECS) from Alibaba Cloud service provider as an example.

ECS server instance

To install MSSQL server on a Ubuntu 16.04 (Xenial Xerus) you will need a server instance that meets the minimum requirements. The below table shows the minimum requirements needed for an ECS server instance to host an MSSQL database server. (source)

Memory 2 GB
CPU 1 Core (x64 bit)
Disk Memory 6 GB
Linux OS At least Ubuntu 16.04

After provisioning your machine, remote into your ECS instance using an SSH compatible client (e.g.: Putty.exe). When logged in, check the details of your instance using the following command:

lsb_release -a

Install and configure MSSQL server

Download MSSQL server installation files using Ubuntu repository. You may need to install common Ubuntu tools before you can use add-apt-repository.

# additional tools might be needed
sudo apt-get install software-properties-common

# update repository and pull MSSQL from repository
curl | sudo apt-key add -

sudo add-apt-repository "$(curl"

sudo apt-get update
If you encounter the error 'sudo: unable to resolve host ' , check the file "/etc/hostname" for the host file DNS entries. (source)

After successfully installing the SQL server, configure the server using the following commands. Follow this up by running a few commands to check the configuration.

# This will launch a prompt to setup SA user.
sudo apt-get install -y mssql-server
sudo /opt/mssql/bin/mssql-conf setup

# Open port 1433 for remote access (optional)
sudo iptables -A INPUT -p tcp --dport 1433 -s -j ACCEPT
# to delete iptable entry, replace -I with -D

# check that 1433 is opened and MSSQL is listening on that port
lsof -i -P | grep :1433
netstat -an | grep :1433

# Check that SQL server
systemctl status mssql-server

Install MSSQL command CLI

Install the Microsoft SQL command line interface (CLI) and use it to create a new SQL user.

curl | sudo apt-key add -
sudo add-apt-repository "$(curl"

sudo apt-get update
sudo apt-get install -y mssql-tools unixodbc-dev

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

# Check that the CLI tools are installed, bcp and sqlcmd should exist in
ls /opt/mssql-tools/bin/

Create SQL user (Optional)

sqlcmd -S localhost -U SA -P 'password_here'
CREATE LOGIN login_name WITH PASSWORD = 'new_password_here';
CREATE USER db_user_name FOR LOGIN login_name;
GRANT ALTER TO db_user_name;
GRANT CONTROL TO db_user_name;

source - Install MSSQL on Ubuntu