SQL Server on Linux: Installation and Management Guide

This guide provides comprehensive instructions for installing, updating, and managing SQL Server 2017 (14.x), SQL Server 2019 (15.x), and SQL Server 2022 (16.x) on Linux operating systems. Whether you are deploying SQL Server for development, testing, or production, this article will walk you through the necessary steps to get your database server up and running on your Linux environment.

For those seeking quick installation steps, you can jump directly to our quickstart guides tailored for different Linux distributions. If you have general questions about running SQL Server on Linux, our SQL Server on Linux FAQ provides answers to common inquiries.

Understanding SQL Server Support on Linux

Before diving into installation, it’s crucial to understand Microsoft’s support policy for SQL Server on Linux. This policy ensures you are operating within supported configurations for optimal performance and reliability.

Term Definition
Servicing Microsoft provides General Distribution Releases (GDR), hotfixes, and security updates for supported Linux distributions throughout the product lifecycle.
Support Microsoft offers technical support for users encountering issues on officially supported Linux distributions.

Linux Distribution Support Lifecycle

Microsoft supports SQL Server on Linux distributions for a duration that is limited by either the distribution’s support lifecycle or the SQL Server support lifecycle, whichever comes first. This means staying updated with your Linux distribution’s support status is as important as keeping up with SQL Server updates.

Servicing Updates on Linux

During the Mainstream Support phase of SQL Server, Cumulative Updates (CUs) are released for all Linux distributions that are also in their Mainstream Support phase. For Linux distributions in Extended Support that are still considered supported platforms for SQL Server, Microsoft may, at its discretion, release CUs and bug fixes.

Once SQL Server transitions to Extended Support, only security updates and General Distribution Releases (GDR) are published. Importantly, these updates are not extended to Linux distributions that have reached the end of their support period. This policy highlights the importance of using actively supported Linux distributions for your SQL Server deployments.

Supported Linux Platforms for SQL Server

SQL Server is officially supported on several major Linux distributions, ensuring compatibility and stability for your database workloads. These distributions include Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), and Ubuntu. Furthermore, SQL Server can be deployed as a container image, offering flexibility across Kubernetes, OpenShift, and Docker Engine on Linux.

Platform File system Installation guide
Red Hat Enterprise Linux 7.7 – 7.9 Server 1, or 8.x Server XFS or EXT4 Installation guide for RHEL
SUSE Linux Enterprise Server v12 SP3 – SP5 2 XFS or EXT4 Installation guide for SLES
Ubuntu 18.04 LTS 3 XFS or EXT4 Installation guide for Ubuntu
Docker Engine 1.8+ on Linux N/A Installation guide for Docker

1 Note that Red Hat Enterprise Linux 7.x transitioned from mainstream maintenance to extended lifecycle support (ELS) at the end of June 2024. For detailed information, refer to Red Hat Enterprise Linux Life Cycle.

2 SUSE Linux Enterprise Server v12 will transition from standard general support to long term service pack support (LTSS) by the end of October 2024. More details are available at Product Support Lifecycle Lifecycle Dates by Product.

3 Ubuntu 18.04 LTS moved from standard maintenance to expanded security maintenance (ESM) at the end of April 2023. For further details, see Ubuntu 18.04 end of standard support.

Tip: For in-depth information, review the system requirements for SQL Server on Linux. For the most current SQL Server support policy, see the Technical support policy for Microsoft SQL Server.

For production environments, it is highly recommended to use supported platforms such as Red Hat Enterprise Linux, SUSE Linux Enterprise Server, and Ubuntu Pro. These platforms provide regular security updates and enterprise-grade support options crucial for database deployments.

Platform File system Installation guide Get
Red Hat Enterprise Linux 7.7 – 7.9 Server 1, or 8.x Server XFS or EXT4 Installation guide for RHEL Get RHEL 8
SUSE Linux Enterprise Server v12 (SP3 – SP5) 2 , or v15 (SP1 – SP3) XFS or EXT4 Installation guide for SLES Get SLES v15
Ubuntu 18.04 3 or 20.04 XFS or EXT4 Installation guide for Ubuntu Get Ubuntu 20.04
Docker Engine 1.8+ on Windows, Mac, or Linux N/A Installation guide for Docker Get Docker

1 At the end of June 2024, RHEL 7.x transitioned to Extended Lifecycle Support (ELS). See Red Hat Enterprise Linux Life Cycle.

2 SLES v12 will transition to Long Term Service Pack Support (LTSS) by the end of Oct 2024. See Product Support Lifecycle Lifecycle Dates by Product.

3 Ubuntu 18.04 LTS transitioned to Expanded Security Maintenance (ESM) at the end of April 2023. See Ubuntu 18.04 end of standard support.

Tip: For more details, check the system requirements and the Technical support policy for Microsoft SQL Server.

For the latest versions, consider these platforms:

Platform File system Installation guide Get
Red Hat Enterprise Linux 8.x Server, or 9.x Server XFS or EXT4 Installation guide for RHEL Get RHEL 9
SUSE Linux Enterprise Server v15 (SP1 – SP4) XFS or EXT4 Installation guide for SLES Get SLES v15
Ubuntu 20.04, or 22.04 XFS or EXT4 Installation guide for Ubuntu Get Ubuntu 22.04
Docker Engine 1.8+ on Linux N/A Installation guide for Docker Get Docker

Tip: Refer to the system requirements and Technical support policy for Microsoft SQL Server for more information.

Microsoft also provides support for deploying and managing SQL Server containers using orchestration platforms like OpenShift and Kubernetes, further expanding deployment options.

Note: While SQL Server is tested and fully supported on the listed distributions, installing on unsupported operating systems should be approached with caution. Review the Support policy section of the Technical support policy for Microsoft SQL Server to fully understand the support implications if you choose to proceed with an unsupported OS.

SQL Server on Linux: Minimum System Requirements

Ensuring your Linux system meets the minimum requirements is essential for a stable and functional SQL Server instance. Below are the basic system requirements:

Requirement Specification
Memory 2 GB 1
File System XFS or EXT4 (BTRFS and other file systems are not supported)
Disk space 6 GB
Processor speed 2 GHz
Processor cores 2 cores
Processor type x64-compatible only

1 The 2 GB minimum memory is required for SQL Server to start on Linux and accommodate system threads and internal processes. Remember to consider this when configuring max server memory and MemoryLimitMB settings.

When using Network File System (NFS) remote shares for production deployments, adhere to these support requirements:

  • Use NFS version 4.2 or higher. Older NFS versions lack essential features like fallocate and sparse file creation, which are standard in modern file systems.
  • Only locate the /var/opt/mssql directories on the NFS mount. Storing SQL Server system binaries on NFS is not supported.

Configuring Source Repositories for SQL Server on Linux

To install or upgrade SQL Server on Linux, you need to configure the appropriate Microsoft repository. This repository serves as the source from which your system will download and install the SQL Server packages. By default, the quick start guides utilize the Cumulative Update (CU) repository, ensuring you get the latest updates. For detailed information on repository configuration, see Configure repositories for installing and upgrading SQL Server on Linux.

Step-by-step Guide to Install SQL Server on Linux

Installing SQL Server on Linux is primarily done via the command line, providing a straightforward and efficient process. For detailed, step-by-step instructions tailored to your specific Linux distribution, refer to these quickstart guides:

Platform Installation Quickstarts
Red Hat Enterprise Linux (RHEL) SQL Server 2017 on RHEL | SQL Server 2019 on RHEL | SQL Server 2022 on RHEL
SUSE Linux Enterprise Server (SLES) SQL Server 2017 on SLES | SQL Server 2019 on SLES | SQL Server 2022 on SLES
Ubuntu SQL Server 2017 on Ubuntu | SQL Server 2019 on Ubuntu | SQL Server 2022 on Ubuntu
Docker SQL Server 2017 on Docker | SQL Server 2019 on Docker | SQL Server 2022 on Docker

For users interested in cloud deployments, SQL Server on Linux can also be run in an Azure virtual machine. See Provision a SQL VM in Azure for more information.

After installation, optimizing performance is key. Refer to Performance best practices and configuration guidelines for SQL Server on Linux to fine-tune your SQL Server instance.

Updating or Upgrading Your SQL Server on Linux

Keeping your SQL Server instance updated ensures you have the latest features, performance improvements, and security patches. To update the mssql-server package to the newest release, use the platform-specific commands below:

Platform Package Update Commands
RHEL sudo yum update mssql-server
SLES sudo zypper update mssql-server
Ubuntu sudo apt-get update && sudo apt-get install mssql-server

These commands will download the latest package version and update the binaries located in /opt/mssql/. Your user databases and system databases remain untouched during this process.

To perform a major version upgrade of SQL Server, you must first change your configured repository to point to the desired SQL Server version. Then, use the same update command to initiate the upgrade. Note that this is only feasible if a direct upgrade path exists between your current and target versions.

Rolling Back SQL Server on Linux to a Previous Version

In certain scenarios, you might need to rollback or downgrade SQL Server to a previous release. Follow these steps to perform a downgrade:

  1. Identify the Target Version: First, determine the specific version number of the SQL Server package you wish to downgrade to. Consult the release notes for a list of package numbers.
  2. Execute Downgrade Command: Use the appropriate command for your Linux distribution, replacing <version_number> with the identified version.
Platform Package Downgrade Commands
RHEL sudo yum downgrade mssql-server-<version_number>.x86_64
SLES sudo zypper install --oldpackage mssql-server=<version_number>
Ubuntu sudo apt-get install mssql-server=<version_number> && sudo systemctl start mssql-server

Note: Downgrading is only supported within the same major version of SQL Server, such as downgrading between different releases of SQL Server 2022 (16.x).

Verifying the Installed SQL Server Version on Linux

To confirm the current version and edition of SQL Server running on your Linux system, follow these steps:

  1. Install SQL Server Command-Line Tools: If you haven’t already, install the sqlcmd and bcp command-line tools. Instructions can be found here: Install SQL Server command-line tools.
  2. Run sqlcmd to Check Version: Use the sqlcmd utility to execute a Transact-SQL command that retrieves and displays the SQL Server version and edition:
sqlcmd -S localhost -U sa -Q 'select @@VERSION'

Uninstalling SQL Server on Linux

If you need to completely remove the mssql-server package from your Linux system, use one of the following commands based on your distribution:

Platform Package Removal Commands
RHEL sudo yum remove mssql-server
SLES sudo zypper remove mssql-server
Ubuntu sudo apt-get remove mssql-server

Note that removing the package alone does not delete the database files that were created. To also remove the database files, execute this command:

sudo rm -rf /var/opt/mssql/

Performing Unattended Installations of SQL Server on Linux

For automated deployments or scripting, you can perform unattended installations of SQL Server. The following example demonstrates how to set up SQL Server Developer edition without prompts, using environment variables to accept the EULA and set the sa password:

sudo MSSQL_PID=Developer ACCEPT_EULA=Y MSSQL_SA_PASSWORD='<your_password>' /opt/mssql/bin/mssql-conf -n setup

Caution: Ensure your password adheres to SQL Server’s password policy. Passwords must be at least eight characters long and include characters from at least three of the following sets: uppercase letters, lowercase letters, digits, and symbols. For enhanced security, use longer and more complex passwords.

You can incorporate this command into larger scripts to handle more complex installation scenarios, including installing additional SQL Server packages.

For more elaborate scripting examples, refer to the provided documentation samples.

Offline Installation of SQL Server on Linux

In environments without direct internet access, you can perform an offline installation of SQL Server. This involves downloading the necessary package files beforehand.

Tip: If you have successfully installed SQL Server using the quick start guides, you do not need to follow these offline steps. This section is specifically for offline scenarios.

  1. Download SQL Server Package: Download the database engine package for your specific Linux platform. Package download links can be found in the package details section of the Release notes for SQL Server 2022 on Linux.
  2. Transfer Package to Linux Machine: Move the downloaded package to your offline Linux machine. Tools like scp can be used if you downloaded the package on a different machine.
  3. Install Database Engine Package: Install the package using the appropriate command for your platform. Replace mssql-server_versionnumber.x86_64.rpm or mssql-server_versionnumber_amd64.deb with the actual file name you downloaded.
Platform Package Installation Command
RHEL sudo yum localinstall mssql-server_versionnumber.x86_64.rpm
SLES sudo zypper install mssql-server_versionnumber.x86_64.rpm
Ubuntu sudo dpkg -i mssql-server_versionnumber_amd64.deb

Note: While rpm -ivh can be used for RPM packages (RHEL and SLES), the commands above automatically handle dependency resolution if dependencies are available in approved repositories.

  1. Resolve Missing Dependencies: You might encounter missing dependencies during the installation. If so, and if you have access to repositories containing these dependencies (even offline repositories), use apt-get -f install on Ubuntu to resolve them. For manual dependency inspection, use:
Platform List Dependencies Command
RHEL rpm -qpR mssql-server_versionnumber.x86_64.rpm
SLES rpm -qpR mssql-server_versionnumber.x86_64.rpm
Ubuntu dpkg -I mssql-server_versionnumber_amd64.deb

After resolving dependencies, retry installing the mssql-server package.

  1. Complete SQL Server Setup: Finish the SQL Server setup process using mssql-conf:
sudo /opt/mssql/bin/mssql-conf setup

SQL Server Licensing and Pricing

SQL Server licensing is consistent across both Linux and Windows platforms. For comprehensive details on licensing and pricing, please visit How to license SQL Server and SQL Server Licensing Resources and Documents.

Exploring Optional SQL Server Features

After the base installation, you have the option to install or enable additional SQL Server features to extend functionality and tailor your database environment to specific needs.

Need Help?

Contribute to SQL Documentation

Did you know you can contribute to and improve SQL Server documentation? By contributing, you help enhance the resources for the entire community and receive recognition as a contributor. For more information, see Edit Microsoft Learn documentation.

Related Resources

SQL Server on Linux FAQ
SQL Server on Linux Release Notes
Performance best practices and configuration guidelines for SQL Server on Linux

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *