DEV Community

Kemal Cholovich
Kemal Cholovich

Posted on • Edited on

#002 How to install MS SQL on Ubuntu Server 18.04

Installation

The first thing to do is import the necessary repository key. From the terminal window, issue the following command:

sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
Enter fullscreen mode Exit fullscreen mode

Next, add the repository with the command:

sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"
Enter fullscreen mode Exit fullscreen mode

Update apt with the command:

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

And, finally, install MS SQL with the command:

sudo apt-get install mssql-server -y
Enter fullscreen mode Exit fullscreen mode

Configure MS SQL server

Once the installation completes, you then need to run a setup script and answer the required questions. The script is run with the following command:

sudo /opt/mssql/bin/mssql-conf setup
Enter fullscreen mode Exit fullscreen mode

After answering all of the questions (which includes creating an admin password), you will then need to restart the MS SQL server with the command:

systemctl restart mssql-server.service
Enter fullscreen mode Exit fullscreen mode

Installing the command line tools

You now have a working MS SQL Server. However, in order to work with it you must install the necessary command line tools. To do this, issue the following commands:

sudo apt-get install curl -y
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
sudo apt-get update 
sudo apt-get install mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Where PASSWORD is the password you set up during the MS SQL installation.

That's it. You're ready to begin working with your MS SQL Server on Ubuntu 18.04. It would work on the new version, try it and comment if you have an update or a better solution.

Top comments (0)