Install SQL Server on Ubuntu (Step-By-Step)

The estimated reading time for this post is 2 minutes

Installing SQL Server on Linux was a great experience for me, that I would like to share with you the challenges and some of the scripts. Hope you enjoy reading this blog post and it is informative for you.

Before we start, we do need to install the Ubuntu Server 16.04 version on either physical machine or virtual. I used Hyper-V to host the Linux OS but I found that VirtualBox works much better and smooth with Linux OS. So I suggest you to use VirtualBox to install SQL Server on Ubuntu.

I assume that you already installed Ubuntu Server 16.04 already.

The Ubuntu Server needs to have internet connection all the time during installation.


Step 1: Enter sudo command to change the current user to SuperUser and install the Microsoft GPG Keys into the Ubuntu by the following script:

curl | apt-key add


Step 2: Register SQL Server repository into the Ubuntu by the following script.

curl > /etc/apt/sources.list.d/mssql-server.list


Step 3: Now its time to install SQL Server by using the following script. In some cases the following script does not run and throws an error regarding another process is using the path or variable, which you need to restart the Ubuntu.

sudo apt-get update /*It updates the Microsoft SQL Server repository list, that imported into Ubuntu in the previous step.*/
sudo apt-get install mssql-server


As you see in the above output, it mentions that repository cannot be authenticated. You may ignore this error message.


Now, the SQL Server installation is done!


Step 4: Run the following script to configure the SQL Server instance in Ubuntu.

sudo /opt/mssql/bin/sqlservr-setup



Step 1: Register the Microsoft SQL Server repository in Ubuntu by the following script.

curl > /etc/apt/sources.list.d/msprod.list


Step 2: Run the following script to install the Microsoft SQL Server Tools in Ubuntu.

sudo apt-get update /*It updates the Microsoft SQL Server repository list, that imported into Ubuntu in the previous step.*/
sudo apt-get install mssql-tools


Step 3: Once the packages are downloaded and installed, you are required to accept the license terms and conditions through the following prompt message boxes.



MSSQL-SERVER Service Verification

Now its time to verify, whether the SQL Server instance is running properly on Ubuntu or not, You may use the following script to verify the service.

systemctl status mssql-server


Connecting to SQL Server

We are only able to connect to SQL Server instance in Ubuntu through SQLCMD tool, and you can able to connect to the database engine through SQL Server Management Studio on Windows platform.



Hamid J. Fard

I am SQL Server Data Platform Expert with more than 9 years’ of professional experience, I am currently Microsoft Certified Master: SQL Server 2008, Microsoft Certified Solutions Master: Charter-Data Platform, Microsoft Data Platform MVP and CIW Database Design Specialist. I also do Pig, Hive and Sqoop development regarding Hadoop Big Data platform. After a few years of being a production database administrator I jumped into the role of Data Platform Expert. Being a consultant allows me to work directly with customers to help solve questions regarding database issues for SQL Server.

More Posts

Follow Me:

Leave a Comment

1 Comment threads
1 Thread replies
Most reacted comment
Hottest comment thread
2 Comment authors
Andrej Zafka Recent comment authors
newest oldest most voted
Notify of
Andrej Zafka
Andrej Zafka

Beautiful solution. I just installed SQL Server on Ubuntu Azure VM and connect from SSMS on Window 10. Just 1 typoo – “systemcrl status mssql-server” should be “systemctl status mssql-server”