How To Install SQL Server On Ubuntu
How To Install SQL Server On Ubuntu
SQLShack Español
Introduction
With an increasing number of new servers running on Linux, and even a third of Microsoft’s Azure
virtual machines running Linux, they have made a choice to bring SQL Server to Linux in order to
increase their market share and attract new customers.
Microsoft has started to make inroads outside of Windows environments with different products,
such as Office 365 apps for various mobile phone operating systems, such as iOS and Android as
well as their own Windows Phone OS. Microsoft has stated that they want to deliver a SQL Server
on Ubuntu, Red Hat and SUSE that feels, looks and performs just like the Windows version of the
SQL Server, where users should not be able to see the differences between those, at least from
the front-end perspective.
Things to consider
SQL Server on Linux is still very new, so inconsistent behaviour and partially supported features
can be apparent when using it. Microsoft stated that the preview version of SQL Server on Ubuntu,
Red Hat, SUSE and Docker engine will support the basic capabilities such as the core database
engine components that support transactional processing and data warehousing. At the moment,
as stated by Microsoft in their release notes for SQL Server on Linux, even in the latest
Community Tech Preview 2.0 (CTP 2.0), there are still a lot of features which aren’t supported, so
there is still work to be done in that field. Nevertheless, it is a huge step for Microsoft, and one that
many DBAs have looked forward to.
System requirements
Microsoft hasn’t stated the full system requirements to install SQL Server on Ubuntu, Red Hat,
SUSE and Docker engine, the only thing they noted is that it requires more than 3.25GB of RAM.
Listed below will be the basic minimum system hardware requirements to run Ubuntu, adjusted for
the RAM and HDD space requirements to run SQL Server on Ubuntu:
I t ll ti d
https://www.sqlshack.com/how-to-install-sql-server-on-ubuntu/ 1/9
1/2/2018 How to install SQL Server on Ubuntu
Installation procedure
SQL Server on Linux currently supports a couple of distributions of Linux, those being Red Hat,
SUSE and Ubuntu, as well as Docker engine.
For this article, we are going to install SQL Server on Ubuntu, the latest version being 17.04 at the
time of writing this article.
1. First, open Terminal by clicking right mouse click on desktop and selecting Open Terminal.
Alternatively, you could go to start menu in the top left, opening it and clicking on Terminal
to open it.
2. After opening the Terminal, we are greeted with a window which looks like in the picture
below.
https://www.sqlshack.com/how-to-install-sql-server-on-ubuntu/ 2/9
1/2/2018 How to install SQL Server on Ubuntu
3. It is here where the installation takes place. First, we need to have the public repository’s
GPG keys imported by entering the following command:
4. The user needs to insert the account password before completing the step.
5. After that, we need to have the Microsoft SQL Server’s Ubuntu repository registered. In this
step as in previous, the user needs to enter the account password before completing the
step (but only if 15 minutes from the last action have passed, as this is Ubuntu’s feature to
only type the password only once in 15 minutes to make work flow easier).
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-
server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
6 Now we can install SQL Server on Ubuntu by entering the following commands:
https://www.sqlshack.com/how-to-install-sql-server-on-ubuntu/ 3/9
1/2/2018 How to install SQL Server on Ubuntu
6. Now we can install SQL Server on Ubuntu by entering the following commands:
With this, the package is installed. To completely install SQL Server on Ubuntu we need to
run the mssql-conf setup and follow the prompts. Also, a strong password is recommended
for the creation of SA account (Minimum length of 8 characters, including both uppercase
and lowercase letters and base 10 digits or/and non-alphanumeric symbols). To continue the
setup run the following command:
7. After the install of SQL Server on Ubuntu has been completed, we can check if the service is
started and running by entering the following command:
8. After some time, a software update may be released and that can be handled with a few
lines in the Terminal. First, it is needed to update the apt-get repository lists by running the
command below and entering the account password.
9. After updating the repository lists, all that is needed to update the SQL Server is to run the
above installation command which will update the mssql-server package:
Running these commands will try to download the latest package, afterwards replace the
updated binaries which are located under /opt/mssql. No user-generated databases or
system databases are affected with this operation.
Optionally, users can install SQL Server Tools on Ubuntu to improve their experience. Currently,
the package contains the Command line query utility (sqlcmd) and Bulk import export utility (bcp).
1. First, it is needed to import the public repository’s GPG keys. After running this command, it
is necessary to input the account password.
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list |
sudo tee /etc/apt/sources.list.d/msprod.list
3. Update the sources list and run the installation command with the unixODBC developer
package:
4. After running the second command, user will be prompted to allow the installation
5. After which the user will need to Accept the license terms
6. For the sqlcmd and bcp commands to be able to get accessed from bash shell, PATH
needs to be modified in the ~/.bash_profile using the command:
For non-login and interactive sessions, the PATH needs to be modified accordingly:
https://www.sqlshack.com/how-to-install-sql-server-on-ubuntu/ 5/9
1/2/2018 How to install SQL Server on Ubuntu
7. After completing the installation, a test database is created to check the functionality of the
SQL Server on Ubuntu.
8. As the process completes, the latest SQL Server Management Studio installed on a
Windows machine is started. Since the Ubuntu machine is in the local network, the IP
address is 192.168.1.8. in this case. After connecting with SQL Server credentials (as
Windows authentication doesn’t work in this case), it can be seen that the database we just
created using sqlcmd tool in Linux Terminal is created and the server is reachable.
In addition to SQL Server Tools, SQL Server Agent can also be installed as an addition after we
install SQL Server on Ubuntu to manage and run scheduled jobs.
1. Update the sources list and run the installation command, after which the Terminal will
prompt to restart the SQL Server for the Agent to be able to start.
After that, connecting to the server in SSMS shows up that the SQL Server Agent is running.
Troubleshooting
Problem
Solutions
Verify if the server is running on the Ubuntu machine by running the command:
https://www.sqlshack.com/how-to-install-sql-server-on-ubuntu/ 6/9
1/2/2018 How to install SQL Server on Ubuntu
After which, running the previous command again should look something like this:
Verify that the firewall has allowed the port 1433 which SQL Server is using by default. First
we need to check the status of the ufw, which is Ubuntu’s Uncomplicated Firewall, by
running the following command and entering the password for the account:
Problem
Solution
To reset the system administrator (SA) password, run the following commands:
Take note that this will temporarily stop SQL Server mssql-server service.
See more
Consider these free tools for SQL Server that improve database developer productivity.
Useful links
Stefan Veselinovic
Support Sales Engineer at ApexSQL
Stefan has gotten into the world of electronics at an early age, always
surrounding himself with something to tinker. After that he got into IT world as
well. He got interested in database management, programming and graphic
design. He strives to improve himself everyday by learning and testing new
things.
Related Posts:
1. SQL Server vNext – Does Microsoft love Linux?
2. A Quick start Guide to Managing SQL Server 2017 on CentOS/RHEL Using the SSH
Protocol
3. Installation of SQL Server vNext CTP on Linux Distribution CentOS 7
4. How to install Microsoft SQL Server Express LocalDB
5. How to install, configure and use SQL Server Distributed Replay
9,189 Views
https://www.sqlshack.com/how-to-install-sql-server-on-ubuntu/ 8/9
1/2/2018 How to install SQL Server on Ubuntu
Sort by Best
Recommend 6 ⤤ Share
LOG IN WITH
OR SIGN UP WITH DISQUS ?
Name
R script word-cloud in SQL Server Report Monitoring SQL Server database status
Builder changes using T-SQL and PowerShell
2 comments • 2 months ago 2 comments • 4 months ago
Metalsimyaci — Thanks for sharing. Waiting Prashanth Jayaram — Hello, Thanks for the
for more... :D great comment. I agree with your view. This
is a great platform for SQL learners:-).Best
How to configure database mail in SQL How to configure SQL Server 2017 on
Server Linux with mssql-conf and other available
6 comments • 2 months ago 4 comments • 2 months ago
Prashanth Jayaram — Hi Bojan, Thanks for Prashanth Jayaram — Hi Karthik,Thanks for
the great write-up. Very informative and the comment. Its a great question.
detailed, touched every bit of the DB Mail Unfortunately we don't have an option to
https://www.sqlshack.com/how-to-install-sql-server-on-ubuntu/ 9/9