Installing SQL Server on Linux (Ubuntu)

How to Install SQL Server on Linux: SQL Server 2025 on Ubuntu 24.04, Step by Step

Install SQL Server 2025 on Ubuntu 24.04 and make it production-ready: supported version pairs, disk layout, mssql-conf settings, the mssql TuneD profile, security, remote connections, patching and uninstalling.

September 25, 2025

SQL Server has run natively on Linux since SQL Server 2017. It’s the same database engine as on Windows, with the same T-SQL, the same backup format and the same query optimizer, running on top of a thin platform abstraction layer. A database backed up on Windows restores on Linux and the other way round.

Installing it takes about ten minutes. Making it production-ready takes more: the right Ubuntu release for your SQL Server version, a sensible disk layout, kernel settings, memory limits, tempdb files, TLS and a patching routine. This guide covers both, using SQL Server 2025 on Ubuntu 24.04 as the main example, with notes for SQL Server 2022 on Ubuntu 22.04.

SQL Server Installation Support

Let's build your SQL Server on Linux production-ready

Our senior DBA team covers the whole build, from version and distribution choice to disk layout, kernel settings, backups and security.

Get Installation Support

Which SQL Server Version Runs on Which Ubuntu Release?

Each SQL Server version has its own package repository per Ubuntu release. If the pair doesn’t match, the repository won’t resolve and the install fails at the first apt-get.

SQL Server version Ubuntu release Supported from
SQL Server 2025 (17.x) 24.04 LTS SQL Server 2025 CU1
SQL Server 2022 (16.x) 22.04 LTS SQL Server 2022 CU10
SQL Server 2019 (15.x) 20.04 LTS SQL Server 2019 CU10
SQL Server 2017 (14.x) 18.04 LTS SQL Server 2017 CU20

For a new production server, use SQL Server 2025 on Ubuntu 24.04 LTS. Besides Ubuntu, SQL Server 2025 supports Red Hat Enterprise Linux (including RHEL 10). SUSE Linux Enterprise Server is no longer supported starting with SQL Server 2025.

Before You Start: Requirements and Disk Layout

Microsoft’s minimum requirements are modest:

  • x64 processor, 2 cores, 2 GHz
  • At least 2 GB of memory
  • At least 6 GB of free disk space
  • XFS or ext4 file system (other file systems such as Btrfs aren’t supported)

Those numbers are enough for a lab. For production, plan the storage before you install:

  • Separate volumes for data files, transaction logs, tempdb and backups, so one workload’s I/O doesn’t hurt another and a full backup disk can’t stop the database.
  • XFS is Microsoft’s recommended file system for data and log files. ext4 is also supported; on kernels older than 5.6 use XFS.
  • Mount the data and log volumes with noatime, and refer to them by UUID in /etc/fstab.
  • On a VM, use fixed memory. Don’t use dynamic memory features such as Hyper-V Dynamic Memory.
# Example /etc/fstab entries (find UUIDs with: sudo blkid)
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1  /sqldata    xfs  rw,attr2,noatime  0 0
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx2  /sqllog     xfs  rw,attr2,noatime  0 0
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx3  /sqltempdb  xfs  rw,attr2,noatime  0 0
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx4  /sqlbackup  xfs  rw,attr2,noatime  0 0

Installing SQL Server 2025 on Ubuntu 24.04

1. Import Microsoft’s package signing key

curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --batch --yes --dearmor -o /usr/share/keyrings/microsoft-prod.gpg

2. Register the SQL Server repository

curl -fsSL https://packages.microsoft.com/config/ubuntu/24.04/mssql-server-2025.list | sudo tee /etc/apt/sources.list.d/mssql-server-2025.list

For SQL Server 2022 on Ubuntu 22.04, the list file is https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list.

Note

Older guides use apt-key and add-apt-repository. apt-key is deprecated on current Ubuntu releases, so use the keyring file and the .list file shown above instead.

3. Install the package

sudo apt-get update
sudo apt-get install -y mssql-server

4. Run the initial configuration

sudo /opt/mssql/bin/mssql-conf setup

The setup asks you to choose an edition and set the sa password. Evaluation, Express and, in SQL Server 2025, Enterprise Developer and Standard Developer are free. Standard and Enterprise need a product key or pay-as-you-go licensing through Azure Arc. Web edition no longer exists in SQL Server 2025.

The sa password must follow the SQL Server password policy: at least eight characters, from at least three of uppercase letters, lowercase letters, digits and symbols, up to 128 characters.

For scripted builds, the same configuration can run without prompts:

sudo MSSQL_PID='Express' ACCEPT_EULA='Y' MSSQL_SA_PASSWORD='<StrongPassword>' \
  /opt/mssql/bin/mssql-conf -n setup

5. Check that the service is running

systemctl status mssql-server --no-pager

6. Open the firewall, narrowly

SQL Server listens on TCP 1433. Allow it only from the networks that need it, never from everywhere:

sudo ufw allow from 10.10.20.0/24 to any port 1433 proto tcp
sudo ufw status

Installing sqlcmd and bcp

The command-line tools come from a separate repository:

curl -fsSL https://packages.microsoft.com/config/ubuntu/24.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo apt-get install -y mssql-tools18 unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc

Then connect and run a quick test:

sqlcmd -S localhost -U sa -C
CREATE DATABASE TestDB;
GO
USE TestDB;
CREATE TABLE dbo.Inventory (id INT PRIMARY KEY, name NVARCHAR(50), quantity INT);
INSERT INTO dbo.Inventory VALUES (1, N'box', 150), (2, N'pallet', 40);
SELECT * FROM dbo.Inventory WHERE quantity > 100;
GO

Tip

The tools in mssql-tools18 encrypt connections by default, and a fresh install uses a self-signed certificate. The -C option trusts that certificate while keeping the connection encrypted. It’s a better choice than turning encryption off with -No; for production, install a proper certificate as shown below.

Configure SQL Server Right After Installation

On Linux, instance settings that Windows exposes in Configuration Manager are set with mssql-conf. Restart the service after changing them.

# Default locations for new databases and backups (folders must be owned by mssql)
sudo mkdir -p /sqldata /sqllog /sqlbackup
sudo chown mssql:mssql /sqldata /sqllog /sqlbackup
sudo /opt/mssql/bin/mssql-conf set filelocation.defaultdatadir /sqldata
sudo /opt/mssql/bin/mssql-conf set filelocation.defaultlogdir /sqllog
sudo /opt/mssql/bin/mssql-conf set filelocation.defaultbackupdir /sqlbackup

# Memory limit for the SQL Server process (MB)
sudo /opt/mssql/bin/mssql-conf set memory.memorylimitmb 28672

# SQL Server Agent is installed but disabled by default
sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true

sudo systemctl restart mssql-server
  • Memory: by default SQL Server on Linux may use up to 80% of physical memory. On a dedicated server that’s often reasonable; leave enough for the OS and any agents, and also set max server memory inside SQL Server. Our max server memory guide explains how to size it.
  • tempdb: setup on Linux creates a single tempdb data file. Add files after installation, typically one per core up to eight, all the same size. See our tempdb best practices.
  • SQL Server Agent: enable it if you schedule backups, index maintenance or CHECKDB from SQL Server itself.
  • Write-through and FUA: on Ubuntu 18.04 or later with XFS (kernel 4.18+) or ext4 (kernel 5.6+) and storage that supports Forced Unit Access, Microsoft recommends trace flag 3979 with control.alternatewritethrough = 0. Otherwise keep the defaults.

Tune Ubuntu for SQL Server

Microsoft publishes a TuneD profile named mssql that collects its kernel recommendations. It ships with RHEL; on Ubuntu, install the tuned package and create the profile yourself.

sudo apt-get install -y tuned
sudo mkdir -p /usr/lib/tuned/mssql
sudo tee /usr/lib/tuned/mssql/tuned.conf > /dev/null <<'EOF'
[main]
summary=Optimize for Microsoft SQL Server
include=throughput-performance

[cpu]
force_latency=5

[sysctl]
vm.swappiness = 1
vm.dirty_background_ratio = 3
vm.dirty_ratio = 80
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
vm.transparent_hugepages=always
vm.max_map_count=1600000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
kernel.numa_balancing=0
EOF
sudo tuned-adm profile mssql
tuned-adm active
Setting Recommended value Why
vm.swappiness 1 Keeps SQL Server’s memory in RAM instead of swapping it out
vm.max_map_count At least 262144 (profile uses 1600000) The default 65536 can be too low for SQL Server
kernel.numa_balancing 0 Automatic NUMA balancing hurts SQL Server on multi-node NUMA systems
Transparent huge pages Enabled (madvise for multi-instance servers) Gives the most consistent performance for a single instance
CPU governor performance Applied by the throughput-performance base profile
Disk read-ahead 4096 Set per device with blockdev; not covered by the profile

Warning

Keep a properly sized swap file anyway. vm.swappiness = 1 makes swapping rare, but with no swap at all, a sudden memory spike can make the kernel’s out-of-memory killer stop the SQL Server process.

Security Basics on Linux

  • Disable sa: create your own sysadmin login, reconnect with it, then run ALTER LOGIN sa DISABLE;. For Windows authentication on Linux, join the server to Active Directory with adutil.
  • Restrict the network: 1433 open only to application servers and admin networks. Never expose SQL Server directly to the internet.
  • Use TLS with a real certificate: set network.tlscert, network.tlskey and network.forceencryption with mssql-conf. SQL Server 2025 on Linux supports TLS 1.3.
  • Back up from day one: the backup format is the same as on Windows. Write backups to a separate volume or a mounted network share, and copy them off the server.

The rest of the hardening list, from permissions to auditing, applies unchanged on Linux; see our SQL Server security hardening guide.

Connecting Remotely

SSMS, VS Code with the MSSQL extension and every application driver connect to SQL Server on Linux the same way they connect to Windows. Use the server’s name or IP address and port 1433. If a remote connection fails while local sqlcmd works, check in this order:

  • Is the firewall rule there for the client’s subnet (sudo ufw status)?
  • Is SQL Server listening on the expected port (sudo ss -tlnp | grep 1433)?
  • Has the port been changed with network.tcpport, or is a network firewall between the client and the server blocking it?
  • Does the client fail on certificate validation? Install a trusted certificate rather than disabling encryption on the client.

Updating SQL Server on Linux

Cumulative updates are delivered through the same repository. Installing the package again brings the server to the latest CU:

sudo apt-get update
sudo apt-get install -y mssql-server

# List available builds and install a specific one (also used to roll back)
apt-cache madison mssql-server
sudo apt-get install -y mssql-server=<version>

Warning

A plain apt-get upgrade also updates mssql-server and restarts the service. On production servers, hold the package (sudo apt-mark hold mssql-server) and install CUs in a planned maintenance window, after checking the build isn’t on a known-issues list. Our dangerous SQL Server builds article explains why.

What’s Different from SQL Server on Windows

The engine is the same, but the platform around it isn’t:

  • Analysis Services and Power BI Report Server run only on Windows. Integration Services runs on Linux with some limitations.
  • Always On availability groups and failover cluster instances use Pacemaker instead of Windows Server Failover Clustering. See our Always On guide for how AGs work.
  • Windows authentication requires joining Active Directory and configuring a keytab.
  • Configuration is done with mssql-conf instead of Configuration Manager, and logs are under /var/opt/mssql/log.
  • Licensing is the same as on Windows, per core or Server + CAL.

Uninstalling SQL Server from Ubuntu

sudo apt-get remove -y mssql-server
# Removes data, logs and configuration permanently
sudo rm -rf /var/opt/mssql/

Critical

Removing the package leaves the databases in /var/opt/mssql, but deleting that folder destroys every database and the master database. Take and verify backups, and move any database files stored in custom folders, before you delete anything.

Production Checklist

  • SQL Server version and Ubuntu release are a supported pair.
  • Data, log, tempdb and backup are on separate XFS volumes mounted with noatime.
  • The mssql TuneD profile is active and swap is configured.
  • Memory limit and max server memory are set.
  • tempdb has multiple equally sized data files.
  • SQL Server Agent is enabled if jobs run on the server.
  • sa is disabled, 1433 is restricted, TLS uses a trusted certificate.
  • Backups are scheduled, copied off the server and restore-tested.
  • mssql-server is held in apt and patched on a schedule.
Yes. SQL Server on Linux runs the same database engine, query optimizer and storage engine as on Windows. Differences in practice come from hardware, storage, kernel settings and configuration, which is why the TuneD profile and disk layout matter.
Ubuntu 24.04 LTS, which is supported starting with SQL Server 2025 CU1. SQL Server 2022 is supported on Ubuntu 22.04.
XFS is Microsoft’s recommended file system for SQL Server data and log files on Linux. ext4 is also supported. Other file systems such as Btrfs aren’t supported.
Yes. The backup format is the same. Copy the .bak file to the Linux server and restore it, using WITH MOVE to place the files under Linux paths. The target version must be the same or newer than the source.
Only the free editions: Express, Evaluation and the Developer editions. Standard and Enterprise on Linux are licensed exactly like on Windows.
Run apt-get update and apt-get install mssql-server to move to the latest cumulative update from the configured repository. On production, hold the package and patch in a planned window.

SQL Server on Linux Support

Running SQL Server on Linux in production?

Aryasoft’s senior DBA team designs and builds SQL Server on Linux servers, from disk layout and kernel tuning to high availability with Pacemaker, backups, security and ongoing patching.

4.7/5