Last Update: Sep 25, 2023 | Published: Aug 02, 2023
Starting with SQL Server 2017, Microsoft has supported SQL Server on Linux, which has the same underlying database engine as the Windows version. In this article, I’ll show you how to install SQL Server on Linux, as well as Azure Data Studio. The most recent release of SQL Server is SQL Server 2022, which offers the same core relational database management features on both Windows and Linux.
By adding Linux support for SQL Server a couple of years ago, Microsoft allowed its platform to better compete with other native Linux database platforms such as Oracle, MySQL and PostgreSQL. To enable Linux compatibility, SQL Server uses a platform abstraction layer (PAL) that separates platform specific code from the rest of the codebase, enabling the core database engine to be operating system agnostic.
If the core database capabilities are the same across Windows and Linux, there are still some differences between the Linux version of SQL Server 2022 and the Windows version. However, just like the Windows editions SQL Server on Linux comes in the following editions:
You can find out all of the specifics about the editions and the supported features in the Linux version of SQL Server 2022 at: Editions and supported features of SQL Server 2022 (16.x) on Linux.
SQL Server 2022 is officially supported on the following Linux distributions:
SQL Server on Linux can also be installed on several other Linux distributions, but these three are the only Linux distributions supported by Microsoft. In addition, Microsoft provides Docker container images that can be run of virtually all Linux platforms that support Docker.
Each distribution has a somewhat different installation process, but the features that are provided by SQL Server 2022 are exactly the same for each of the different distributions.
Installing SQL Server on Linux is quite different from installing it on Windows. There is no self-contained installation executable on Linux, so you’ll need to run a series of commands from the Linux Terminal to install SQL Server 2022.
The different Linux distributions have slightly different installation processes. Microsoft provides installation instructions for Red Hat Enterprise Linux 7.2, Ubuntu 16.04 and SUSE Enterprise Server v12 SP2. In this article, I’ll be detailing how install SQL Server on Ubuntu 20.04.
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2022.list)"
sudo apt-get update sudo apt-get install -y mssql-server
When these commands have finished running, your Terminal display will look something like the following figure.
sudo /opt/mssql/bin/mssql-conf setup
The entire setup and initial configuration process is quite fast – it should only take a few minutes from start to finish. Once the mssql-conf setup has finished, the SQL Server service will start. You can verify that the mssql-server service is running by using the following command:
systemctl status mssql-server --no-pager
If you want networked client systems to be able to connect remotely, you will also need to open the SQL Server default TCP port 1433 on your Linux firewall.
At this point, SQL Server is up and running on Ubuntu, and you can connect to it using either command line tools or SQL Server management and development tools such as SQL Server Management Studio (SSMS) or Azure Data Tools (ADT).
After SQL Server on Linux has been installed, you’ll want to connect to it for development, management, data transfer, and other database actions. There are a number of different Microsoft tools that you can use to connect to the SQL Server database engine on Linux including:
Azure Data Studio (ADS) is a great option for your initial connection and management of SQL Server 2022 on Linux. It’s a native Linux application, it’s also easy to install and has an easy-to-use graphical user interface. ADS provides both development and management capabilities that can help you get your SQL Server on Linux projects up and running quickly and easily.
When Azure Data Studio first starts up, you’ll be prompted to create a new database connection using the New > New connection option from the initial Welcome screen. This will display the Connections dialog where you can input the following database connection values:
After completing the Connection dialog, you’ll see the following where Azure Data Studio is connected to your new SQL Server 2022 Linux installation. At this point you have SQL Server on Linux running and a graphical management and development environment on top of it allowing you to restore, migrate and create new SQL Server database projects.
The process for installing SQL Server 2022 is quite straightforward. I hope that this tutorial will help you perform the initial configuration of SQL Server 2022 on Ubuntu Linux, as well as install and connect Azure Data Studio to your new SQL Server on Linux installation. Thank you for reading, and feel free to check out other articles in my onging SQL Server Essentials series on Petri.
Related Articles: