Learn how to Install SQL Server 2019 in Ubuntu 20.04 LTS. Lets just start straightaway. While it is a straightforward process in Microsoft Windows operating system, it is different in Ubuntu (or Debian based supported distributions).
If you are in a rush and/or are too pro to skip this, I have also provided a Shell script. The shell script can be found HERE! but I recommend reading this post to make sure nothing is skipped and the installation of Microsoft SQL Server 2019 goes smoothly.
codeonion:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04 LTS Release: 20.04 Codename: focal
Lets Begin Installation of Microsoft SQL Server 2019 in Ubuntu 20.04
Install software-properties-common
sudo apt install software-properties-common
sudo apt-get update
Import the public repository GPG keys:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
Register the Microsoft SQL Server Ubuntu repository for SQL Server 2017:
https://packages.microsoft.com/config/ubuntu/20.04/
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"
Install Microsoft SQL Server 2019 in Ubuntu
sudo apt update
sudo apt install mssql-server

We are recommended to run a command

sudo /opt/mssql/bin/mssql-conf setup
Pick your Microsoft SQL Server 2019 Edition

When prompted, accept the license and then set up a PASSWORD
Confirm Microsoft SQL Server 2019 Active Status
systemctl status mssql-server.service
Should show active running database server

Install Microsoft SQL TOOLS mssql-tools
Lets now install mssql-tools. But first!! Acquire the power of Sudo Su!
sudo su
This breaks all the walls and lets you do whatever the crap you want. So be careful :). Now do the following.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/19.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt update
sudo ACCEPT_EULA=Y apt install mssql-tools unixodbc-dev
Configure PATH for MS SQL binaries
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/19.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt update
sudo ACCEPT_EULA=Y apt install mssql-tools unixodbc-dev
Now connect to your server using
sqlcmd -S 127.0.0.1 -U sa -P <yourpassword>
Shell Script to Install Microsoft SQL Server 2019 in Ubuntu 20.04
Finally, I will be an ass if I didn’t make a shell script of this process so:
First
sudo su
Then run the following shell script (replace your password at the bottom of the script)
!/bin/bash lsb_release -a sudo apt install software-properties-common -y sudo apt install curl -y sudo apt-get update wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)" sudo apt-get update sudo apt-get install -y mssql-server sudo /opt/mssql/bin/mssql-conf setup systemctl status mssql-server --no-pager curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list sudo apt-get update sudo apt-get install mssql-tools unixodbc-dev -y echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc sqlcmd -S 127.0.0.1 -U sa -P <YOUR PASSWORD HERE>
Then test the following query
SELECT Name from sys.Databases;
GO
And you will see:

That may be the end of it. Let me know if it helped. Please comment and share if it helped. Lets us know.
Thanks.
6 responses to “Install SQL Server 2019 in Ubuntu 20.04 LTS”
I am trying 20.04 Got almost to the end and then the errors showed up: root@ubuntu:/home/markwardell# sudo ACCEPT_EULA=Y apt install mssql-tools unixodbc-dev
Reading package lists… Done
Building dependency tree
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mssql-tools : Depends: msodbcsql17 (>= 17.3.0.0) but it is not going to be installed
unixodbc-dev : Depends: unixodbc (= 2.3.7)
Depends: odbcinst1debian2 (= 2.3.7) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I’m experiencing the same problem here. From what I’ve done, I just installing the missing dependencies. For eg, in your case, your installation stated that it ‘Depends: msodbcsql17…’, so try to install it, by using this command: sudo apt-get install msodbcsql17 and hit enter.
surely it may ask for the other dependency, and try to install that ones too.(normally this will be the other case as stated above, which is the ‘unixodbc’ dependency so it may be: sudo apt-get install unixodbc and also the odbcinst1debian2).
Try again the mssql-tools installation and see what happens..
You can try to see this complete reference at:
https://itsfoss.com/held-broken-packages-error/
Good Luck!
Sir,
I tried 2 full days to install “SQL SERVER 2019 EXPRESS” on my Ubuntu 20.04 machine, but was unsuccessful due to package/dependencies issues. None of the resources (Microsoft official docs, youtube videos, stacke overflow etc..) helped trouble shoot the problem.
Finally got to know that Ubuntu 20.04 is not supported for the MSSQL server 2019 at this moment.
So, I literally gave up on the direct installation of the SQL Server & started trying to install it through Docker – which is when I came across your article which worked like a charm.
Thank you so much for posting this article Sir. It really meant a great help.
Can I please know the details of the author if it ain’t confidential?
Best!!
Hi. I am really glad that the article was helpful to you. You can find me as “codeonion” in twitter, facebook and elsewhere 🙂
Sir,
Can you please guide me “How to install “SQL Server Management Studio” in Ubuntu 20.04??
It would be really helpful if you could.
Thanks in advance.
It is officially unsupported by Microsoft on Ubuntu 20.04. I would advise you to use Azure Data Studio 😉