Bobcares

How to install MS SQL Server 2017 on Ubuntu 18.04

by | Jan 14, 2021

Wondering how to install MS SQL Server 2017 on Ubuntu 18.04? We can help you.

At Bobcares, we assist our customers with several installations as part of our Server Management Service.

Today, let us see how our Support Engineers install MS SQL Server 2017 on Ubuntu 18.04

 

How to install MS SQL Server 2017 on Ubuntu 18.04

In 2016, Microsoft’s relational database, MS SQL, was released under an open-source license.

Installing MS SQL on Ubuntu Server 18.04 is actually quite easy. Once you have it installed, the database server will function smoothly.

In order to begin the installation, our Support Engineers suggest having a working Ubuntu 18.04 Server instance and a user with

sudoCopy Code
privileges.

We can run the MS SQL Server with a trial license, but beyond that, we will need to purchase a license to put the MS SQL Server into production usage.

How to install MS SQL Server 2017 on Ubuntu 18.04

Access the Ubuntu server using SSH

Moving ahead let us focus on the step-by-step process of accessing the Ubuntu Server using SSH.

  • Step 1: Update and upgrade the OS

To update, we run the following command:

$ sudo apt-get updateCopy Code

On the other hand, to upgrade, we run:

$ sudo apt-get upgrade

$ sudo apt install software-properties-commonCopy Code
  • Step 2: Import public repository GPG keys

We can import public repository GPS keys by running the following command:

$ sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –Copy Code
Expected Output: OKCopy Code

However, if we get any error we try the following commands and retry the above command again:

$ sudo apt-get remove libcurl4
$ sudo apt-get install libcurl3Copy Code
  • Step 3: Register the Microsoft SQL Server Ubuntu repository

In order to register the MS SQL SQL Server Ubuntu repository, we run:

$ sudo add-apt-repository “$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)”Copy Code

Then we run:

$ sudo apt-get updateCopy Code
  • Step 4: Install SQL server
$ sudo apt-get install -y mssql-serverCopy Code

Wait at least five or six minutes for all packages to download and install.

After successful execution of the above command, SQL Server should finish installation on our machine.

  • Step 5: Set the SA password

After the package installation finishes, we run

mssql-confCopy Code
setup and follow the prompts to set the SA password and choose the edition.

For SQL Server 2017, Evaluation, Developer, and Express are freely licensed. We choose the version by entering a specified number in front of the version name and provide a strong password for SA (System Administrator) account.

$ sudo /opt/mssql/bin/mssql-conf setupCopy Code
Choose an edition of SQL Server:

Evaluation (free, no production use rights, 180-day limit)
Developer (free, no production use rights)
Express (free)
Web (PAID)
Standard (PAID)
Enterprise (PAID)
Enterprise Core (PAID)
I bought a license through a retail sales channel and have a product key to enter.Copy Code

Then type 2 then press Enter.

Do you accept the license terms? [Yes/No]: yesCopy Code

Type SA password two times then.

  • Step 6: Verify if the service is running

Once the configuration is done, we need to verify that the server is running.

$ systemctl status mssql-serverCopy Code

In case we need to give the service a restart, we run:

$ systemctl restart mssql-server.serviceCopy Code

Now the SQL Server has installed we can connect to this service remotely if we have SQL Server Management Studio on the Windows machine or install the command line tools from below.

 

Install the SQL Server command-line tools

  • Step 1: Install CURL

We need to install CURL if we do not have it already.

For the installation, we run:

$ sudo apt install curlCopy Code
  • Step 2: Import the public repository GPG keys
$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –Copy Code
  • Step 3: Register the Microsoft Ubuntu repository.
$ curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.listCopy Code

Update the sources list and run the installation command with the unixODBC developer package.

$ sudo apt-get update
$ sudo apt-get install mssql-tools unixodbc-devCopy Code

If we want to update the

mssql-toolsCopy Code
, we run:

$ sudo apt-get update
$ sudo apt-get install mssql-toolsCopy Code

Now it is time to connect. But before that it is better to add /opt/mssql-tools/bin/ to the PATH environment variable

$ export PATH=”$PATH:/opt/mssql-tools/binCopy Code

Connect locally:

$ sqlcmd -S localhost -U SA -P [YourPassword>]Copy Code
sqlcmdCopy Code
is executed with parameters for the SQL Server name (-S), the user name (-U), and the password (-P).

If we connect locally, the server name is localhost. The user name is SA and the password is the one we provided for the SA account during setup.

[Failed to connect remotely? We’d be happy to assist]

 

Conclusion

In short, installing MS SQL on Ubuntu Server 18.04 is actually quite easy. Once we follow the methods our Support Engineers suggest, the database server will function smoothly.

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Speed issues driving customers away?
We’ve got your back!