At this time of writing, Microsoft SQL Server 2019 does not support Ubuntu 22.04. But if you are Ubuntu 22.04 user, there is another way to install SQL Server in your OS, by using Docker. In this tutorial, I will show you how to install SQL Server on Ubuntu 22.04 using Docker. SQL Server can be used to store spatial databases. It supports ArcGIS Pro, QGIS, and other GIS software. It’s a great spatial database that has been used by millions of users out there.
Steps to Install Microsoft SQL Server on Ubuntu 22.04
Step 1. Install Docker
I assume you have a Ubuntu 22.04 desktop or Server edition. First, we need to install Docker on Ubuntu 22.04. Open the Terminal or connect to the server via SSH and then use this command to prepare some basic stuff.
sudo apt update sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release
And then, these commands to add the Docker repository
sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Now update Ubuntu
sudo apt update
Now use this command to install the Docker engine
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Now start Docker and verify the status
sudo service docker start sudo service docker status
Make sure you get the following output
At this point, we have successfully installed Docker. Now we are ready to install Microsoft SQL Server on our Docker container.
Step 2. Install Microsoft SQL Server 2019 on Docker
First, we need to pull the SQL Server image.
sudo docker pull mcr.microsoft.com/mssql/server:2019-latest
Downloading SQL Server Docker Image
Now let’s create the Docker container
sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<YourStrong@Passw0rd>" \ -p 1433:1433 --name sql1 --hostname sql1 \ -d \ mcr.microsoft.com/mssql/server:2019-latest
Don’t forget to change <YourStrong@Password> with your own password. Please read the password complexity requirements. For a complete guide and help with installing SQL Server in Docker, please visit this official page.
Check if the new Docker container is up and running
sudo docker ps -a
At this point, we have successfully installed Microsoft SQL Server 2019 on Ubuntu Docker.
Create a New Database
To create a new database in your SQL Server, you can use the sqlcmd but I will not explain it here. If you prefer the sqlcmd way, please read this article. In this section, I am going to create a new database using Azure Data Studio. It is a free GUI software to manage your SQL Server. It can be used to connect to multiple servers as well as create a new database.
Download and install Azure Data Studio and then create a new connection to the SQL Server we’ve just installed.
Click Create a connection and then enter the SQL Server details
Click Connect to start the connection. Now your SQL Server is ready to be used. To create a new database using Azure Data Studio, right-click on your server and click New Query.
And then type the following command in the query window. Don’t forget to change “test” with your actual database name.
CREATE DATABASE test; GO
Click Run to execute the query. In a few moments, the new database should be ready.
We went through all the steps to install Microsoft SQL Server 2019 on Ubuntu 22.04 using Docker. It is a pretty long step but I think in the end, we have a good result. Thank you for reading this article and see you in the next articles. Stay safe.