Click here to Skip to main content
15,892,298 members
Articles / Database Development / SQL Server
Tip/Trick

Install SQL Server 15.x on Ubuntu Linux Server 18.04 LTS

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
24 Oct 2019CPOL4 min read 5.7K   8   1
This article will walk you with steps on how to install, configure and connect to SQL Server 15.x on,Linux Ubuntu Server 18.04 LTS
This post guides users through installing SQL Server on Ubuntu 18.04, addressing potential installation issues and providing configuration steps to ensure a successful setup, along with instructions for connecting from both Linux and Windows environments.

Introduction

Back in 2017, Microsoft brought its owned RDBMS to the Linux world.

In this post, I’ll get you through the process of installing SQL Server on Ubuntu 18.04. There are a lot of articles on the internet on how to install on this famous operating system, but my article would help you save tremendous time trying to debug installation failures.

Let’s jump into action.

System Requirements

The following table shows the minimum requirements to install SQL Server for Linux (please make sure you have this config in your VM or Server, otherwise SQL Server won’t install):

Image 1

Installation

1. Prepare the Machine

Run the following commands to update your machine:

Shell
sudo apt-get update

Then:

Shell
sudo apt-get upgrade

2. Install libcurl3 instead of libcurl4

Up until this post is written, SQL server for Linux doesn’t support libcurl4. So we need to downgrade libcurl to version:

Uninstall libcurl4 using this command:

Shell
sudo apt-get remove libcurl4

Then install libcurl3 using this command:

Shell
sudo apt-get install libcurl3

The console output should show a message like this showing it was successfully installed:

Image 2

3. Install SQL Server

Now we need to proceed with the normal installation process as indicated in Microsoft official documentation:

  1. Import the public repository GPG keys:
    Shell
    wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
  2. Register the Microsoft SQL Server Ubuntu repository for SQL Server 2019 preview:
    Shell
    sudo add-apt-repository 
    "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"
  3. Run the following commands to install SQL Server:
    Shell
    sudo apt-get update
    sudo apt-get install -y mssql-server

We stop right after installing the package, so we make some config changes, then we continue.

OpenSSL Libraries 1.0 Config

Here are the steps to configure SQL Server to work properly with OpenSSL 1.0:

  1. Stop SQL Server running the following command:
    Shell
    sudo systemctl stop mssql-server
  2. Edit SQL Server service configuration with this command:
    Shell
    sudo systemctl edit mssql-server
  3. In the editor that will open, add the following lines:
    [Service]
    Environment="LD_LIBRARY_PATH=/opt/mssql/lib"

    If you are not familiar with nano editor, you have to paste the above lines, then make the following commands sequentially:

    1. CTRL + O
    2. Enter
    3. CTRL + X
  4. Create symbolic links to OpenSSL 1.0 for SQL Server to use:
    Shell
    sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /opt/mssql/lib/libssl.so
    sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /opt/mssql/lib/libcrypto.so
  5. Start SQL Server:
    Shell
    sudo systemctl start mssql-server

Continue Installation of SQL Server

Now it’s time for the last step, in this step, the command line prompts us to input the edition we want to install, accept licence agreement and then setup SA admin password.

Shell
sudo /opt/mssql/bin/mssql-conf setup

If setup couldn’t successfully run SQL Server, execute the following command:

Shell
sudo systemctl start mssql-server

Check status:

Shell
sudo systemctl status mssql-server

It should display a message that resembles:

Image 3

Hooray, congratulations for making it to this point!!!

Bonus: Connect to SQL Server instance.

From Linux

To connect from Linux, you have to install SQL Server client package.

  1. You need first to install curl:
    Shell
    sudo apt install curl
  2. Import the public repository GPG keys:
    Shell
    curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
  3. Register the Microsoft Ubuntu repository:
    Shell
    curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | 
         sudo tee /etc/apt/sources.list.d/msprod.list
  4. Update the sources list and run the installation command with the unixODBC developer package:
    Shell
    sudo apt-get update
    sudo apt-get install mssql-tools unixodbc-dev

    You will be prompted to accept licences with a Linux command line GUI, just accept each time you are prompted.

  5. Add mssql-tools to your PATH:
    Shell
    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
    echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
  6. Connect:
    Shell
    sqlcmd -S <ServerAddress> -U SA -P '<YourPassword>'

If you experience issues, you will have to indicate the protocol and port in the server address.

Also if you would not like to have your password appear in bash history or your cli prompt, you do not have to specify -P parameter, the tool will prompt you later to input a password.

Example:

Shell
sqlcmd -S tcp:127.0.0.1,1433 -U SA

From External: Allow Port 1433

Before you proceed to login from outside our server, we need to make sure the default TCP port 1433 or changed one is allowed to accept inbound traffic.

If you are on Azure, you have to go to your virtual machine -> Networking, click on Add inbound port rule button.

Image 4

Add inbound rule.

Then specify the port in Destination port ranges field and click Add button.

Image 5

If you are not on Azure, please contact your hosting provider to get ways on how to allow inbound traffic on a specific port.

P.S.: You might need to allow inbound port rules on iptables from command prompt.

Connect from Microsoft SQL Server Management Studio on Windows

If you don’t have Management Studio installed, download it from here.

Like from Linux mssql client tool, you have to specify the protocol and port beside the address, for example:

tcp:<ip_or_domain>,1433

You have to chose SQL Server authentication and enter SA as Login and the password you set when installing the server on Linux.

Image 6

SQL Server login screen

Then the connection gets established.

Image 7

Congratulations on making SQL Server setup on Linux!

References

Points of Interest

Did you learn how to setup MSSQL Server on Linux? How did you find the article?

How likely are you to recommend this article to a friend or professional team mate?

History

  • v1.0 - 23/10/2019: Initial publication

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Accellware LTD
Morocco Morocco
I am a senior/architect level engineer with more than 10 years of experience in developing and maintaining small and big applications. I am based in Paris, France and can align with your office hours, I worked with clients in the US and the rest of the world.

Sir, I can help you in architectural documentation, analysis and conception, environment setup and technology choice.

I work based on industry standards and excels in the following methodology:
- Domain Driven Design
- Distributed systems design especially with microservices
- Test Driven Development
- SOLID principle
- Unified process using UML
- Agile methodology
- Continuous delivery/Integration
- ... and more

Regarding technologies I master and sufficient but not limited to the following:
- Asp.net MVC with .net Framework and Core
- Angular
- jQuery
- Bootstrap
- MSSql Server
- Mongo Db
- Cassandra
- Redis
- Docker
- Powershell
- Azure services
- AWS

Developing an application is an easy task for some, they just code before they think. The client at the end pays a lot just to maintain the code base because it wasn't built with maintainability in mind. This is why I offer you my services and guarantee you that the code I ship is of high quality.

Comments and Discussions

 
QuestionIdea Pin
mag1327-Oct-19 0:27
mag1327-Oct-19 0:27 
instead on this lines of commands, whay don't create an Image on Unbutu x.x with SQL YYY installed/or an docker image ?
magsoft

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.