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.

Install MSSQL-SERVER

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 https://packages.microsoft.com/keys/microsoft.asc | apt-key add

step-1

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

curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list > /etc/apt/sources.list.d/mssql-server.list

step-2

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

step-3-1

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

step-3-2

Now, the SQL Server installation is done!

step-3-3

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

sudo /opt/mssql/bin/sqlservr-setup

step-4

Install MSSQL-TOOLS

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

curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/msprod.list

step-5

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-6

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.

step-7

step-8

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

sqllinux-14

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.

SQLCMD

sqllinux-15

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:
FacebookLinkedIn


Leave a Comment

2 Comments on "Install SQL Server on Ubuntu (Step-By-Step)"

Notify of
avatar
1000
Sort by:   newest | oldest | most voted
Andrej Zafka
Guest

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”

wpDiscuz