| title | Ubuntu: Install SQL Server on Linux | |||
|---|---|---|---|---|
| description | This quickstart shows how to install SQL Server 2017 and later versions on Ubuntu and then create and query a database with sqlcmd. | |||
| author | rwestMSFT | |||
| ms.author | randolphwest | |||
| ms.date | 02/04/2026 | |||
| ms.service | sql | |||
| ms.subservice | linux | |||
| ms.topic | quickstart | |||
| ms.custom |
|
[!INCLUDE SQL Server - Linux]
::: moniker range="=sql-server-linux-2017 || =sql-server-2017"
In this quickstart, you install [!INCLUDE sssql17-md] on Ubuntu 18.04. Then you can connect with sqlcmd to create your first database and run queries.
For more information on supported platforms, see Release notes for SQL Server 2017 on Linux.
::: moniker-end
::: moniker range="=sql-server-linux-ver15 || =sql-server-ver15"
In this quickstart, you install [!INCLUDE sssql19-md] on Ubuntu 20.04. Then you can connect with sqlcmd to create your first database and run queries.
For more information on supported platforms, see Release notes for SQL Server 2019 on Linux.
::: moniker-end
::: moniker range="=sql-server-linux-ver16 || =sql-server-ver16"
In this quickstart, you install [!INCLUDE sssql22-md] on Ubuntu 20.04 or 22.04. Then you can connect with sqlcmd to create your first database and run queries.
For more information on supported platforms, see Release notes for SQL Server 2022 on Linux.
::: moniker-end
::: moniker range=">=sql-server-linux-ver17 || >=sql-server-ver17"
In this quickstart, you install [!INCLUDE sssql25-md] on Ubuntu 22.04. Then you can connect with sqlcmd to create your first database and run queries.
Note
Starting with [!INCLUDE sssql25-md] Cumulative Update (CU) 1, Ubuntu 24.04 is supported.
For more information on supported platforms, see Release notes for SQL Server 2025 on Linux.
::: moniker-end
Tip
This tutorial requires user input and an internet connection. If you're interested in the unattended or offline installation procedures, see Installation guidance for SQL Server on Linux.
Caution
[!INCLUDE password-complexity]
::: moniker range="=sql-server-linux-2017 || =sql-server-2017"
You need an Ubuntu 18.04 machine with at least 2 GB of memory.
To install Ubuntu 18.04 on your own machine, go to https://releases.ubuntu.com/18.04/. You can also create Ubuntu or Ubuntu Pro virtual machines in Azure. See Tutorial: Create and Manage Linux VMs with the Azure CLI.
If you previously installed a preview version of [!INCLUDE ssnoversion-md], you must first remove the old repository before following these steps. For more information, see Configure repositories for installing and upgrading SQL Server on Linux.
::: moniker-end
::: moniker range="=sql-server-linux-ver15 || =sql-server-ver15"
You need an Ubuntu 20.04 machine with at least 2 GB of memory.
To install Ubuntu 20.04 on your own machine, go to https://releases.ubuntu.com/20.04/. You can also create Ubuntu or Ubuntu Pro virtual machines in Azure. See Tutorial: Create and Manage Linux VMs with the Azure CLI.
If you previously installed a preview version of [!INCLUDE ssnoversion-md], you must first remove the old repository before following these steps. For more information, see Configure repositories for installing and upgrading SQL Server on Linux.
::: moniker-end
::: moniker range="=sql-server-linux-ver16 || =sql-server-ver16"
You need an Ubuntu 20.04 or Ubuntu 22.04 machine with at least 2 GB of memory.
To install Ubuntu 20.04 on your own machine, go to https://releases.ubuntu.com/20.04/. You can also create Ubuntu or Ubuntu Pro virtual machines in Azure. See Tutorial: Create and Manage Linux VMs with the Azure CLI.
If you previously installed a preview version of [!INCLUDE ssnoversion-md], you must first remove the old repository before following these steps. For more information, see Configure repositories for installing and upgrading SQL Server on Linux.
::: moniker-end
::: moniker range=">=sql-server-linux-ver17 || >=sql-server-ver17"
You need an Ubuntu 22.04 or 24.04 machine with at least 2 GB of memory.
To install Ubuntu 22.04 on your own machine, go to https://releases.ubuntu.com/22.04/. You can also create Ubuntu or Ubuntu Pro virtual machines in Azure. See Tutorial: Create and Manage Linux VMs with the Azure CLI.
If you previously installed a preview version of [!INCLUDE ssnoversion-md], you must first remove the old repository before following these steps. For more information, see Configure repositories for installing and upgrading SQL Server 2025 on Linux.
::: moniker-end
Note
[!INCLUDE ssnoversion-md] on Windows Subsystem for Linux (WSL) is supported for development purposes only. For instructions on installing SQL Server on WSL, see Quickstart: Install SQL Server and create a database on Windows Subsystem for Linux (WSL 2).
For other system requirements, see System requirements for SQL Server on Linux.
Tip
For production environments that require FIPS compliance or Expanded Security Maintenance (ESM) coverage for Ubuntu Universe packages, use Ubuntu Pro. You can enable Ubuntu Pro on your existing instance, or select a preconfigured Ubuntu Pro image when you provision your virtual machine in Azure.
To configure [!INCLUDE ssnoversion-md] on Ubuntu, run the following commands in a terminal to install the mssql-server package.
::: moniker range="=sql-server-linux-2017 || =sql-server-2017"
-
Import the public repository GPG keys:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc -
Register the [!INCLUDE ssnoversion-md] Ubuntu repository:
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2017.list)"[!TIP]
If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2019, SQL Server 2022, or SQL Server 2025 versions of this article. -
Install [!INCLUDE ssnoversion-md]:
sudo apt-get update sudo apt-get install -y mssql-server
-
After the package installation finishes, run
mssql-conf setupand follow the prompts to set thesapassword and choose your edition. The following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.sudo /opt/mssql/bin/mssql-conf setup
[!CAUTION]
[!INCLUDE password-complexity] -
When the configuration is done, verify that the service is running:
systemctl status mssql-server --no-pager
-
If you plan to connect remotely, you might also need to open the [!INCLUDE ssnoversion-md] TCP port (default 1433) on your firewall.
::: moniker-end
::: moniker range="=sql-server-linux-ver15 || =sql-server-ver15"
-
Import the public repository GPG keys:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc -
Register the [!INCLUDE ssnoversion-md] Ubuntu repository:
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)"[!TIP]
If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017, SQL Server 2022, or SQL Server 2025 versions of this article. -
Install [!INCLUDE ssnoversion-md]:
sudo apt-get update sudo apt-get install -y mssql-server
-
After the package installation finishes, run
mssql-conf setupand follow the prompts to set thesapassword and choose your edition. The following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.sudo /opt/mssql/bin/mssql-conf setup
[!CAUTION]
[!INCLUDE password-complexity] -
When the configuration is done, verify that the service is running:
systemctl status mssql-server --no-pager
-
If you plan to connect remotely, you might also need to open the [!INCLUDE ssnoversion-md] TCP port (default 1433) on your firewall.
::: moniker-end
::: moniker range="=sql-server-linux-ver16 || =sql-server-ver16"
-
Import the public repository GPG keys:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc -
Register the [!INCLUDE ssnoversion-md] Ubuntu repository:
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2022.list)"[!TIP]
If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017, SQL Server 2019, or SQL Server 2025 versions of this article. -
Install [!INCLUDE ssnoversion-md]:
sudo apt-get update sudo apt-get install -y mssql-server
-
After the package installation finishes, run
mssql-conf setupand follow the prompts to set thesapassword and choose your edition. The following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.sudo /opt/mssql/bin/mssql-conf setup
[!CAUTION]
[!INCLUDE password-complexity] -
When the configuration is done, verify that the service is running:
systemctl status mssql-server --no-pager
-
If you plan to connect remotely, you might also need to open the [!INCLUDE ssnoversion-md] TCP port (default 1433) on your firewall.
-
Download the public key, convert it from ASCII to GPG format, and write it to the required location:
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpgIf you receive a warning about the public key not being available, use the following command instead:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc -
Manually download and register the [!INCLUDE ssnoversion-md] Ubuntu repository:
curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list | sudo tee /etc/apt/sources.list.d/mssql-server-2022.list[!TIP]
If you want to install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017, SQL Server 2019, or SQL Server 2025 versions of this article. -
Install [!INCLUDE ssnoversion-md]:
sudo apt-get update sudo apt-get install -y mssql-server
-
After the package installation finishes, run
mssql-conf setupand follow the prompts to set thesapassword and choose your edition. The following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.sudo /opt/mssql/bin/mssql-conf setup
[!CAUTION]
[!INCLUDE password-complexity] -
When the configuration is done, verify that the service is running:
systemctl status mssql-server --no-pager
-
If you plan to connect remotely, you might also need to open the [!INCLUDE ssnoversion-md] TCP port (default 1433) on your firewall.
::: moniker-end
::: moniker range=">=sql-server-linux-ver17 || >=sql-server-ver17"
-
Download the public key, convert it from ASCII to GPG format, and write it to the required location:
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpgIf you receive a warning about the public key not being available, use the following command instead:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc -
Manually download and register the [!INCLUDE ssnoversion-md] Ubuntu repository:
curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2025.list | sudo tee /etc/apt/sources.list.d/mssql-server-2025.list[!TIP]
To install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017, SQL Server 2019, or SQL Server 2022 versions of this article. -
Install [!INCLUDE ssnoversion-md]:
sudo apt-get update sudo apt-get install -y mssql-server
-
After the package installation finishes, run
mssql-conf setupand follow the prompts to set thesapassword and choose your edition. The following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.sudo /opt/mssql/bin/mssql-conf setup
[!CAUTION]
[!INCLUDE password-complexity] -
When the configuration is done, verify that the service is running:
systemctl status mssql-server --no-pager
-
If you plan to connect remotely, you might also need to open the [!INCLUDE ssnoversion-md] TCP port (default 1433) on your firewall.
At this point, [!INCLUDE ssnoversion-md] is running on your Ubuntu machine and is ready to use.
Applies to: [!INCLUDE sssql25-md] CU 1 and later versions.
-
Download the public key, convert it from ASCII to GPG format, and write it to the required location:
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg -
Manually download and register the [!INCLUDE ssnoversion-md] Ubuntu 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[!TIP]
To install a different version of [!INCLUDE ssnoversion-md], see the SQL Server 2017, SQL Server 2019, or SQL Server 2022 versions of this article. -
Install [!INCLUDE ssnoversion-md]:
sudo apt-get update sudo apt-get install -y mssql-server
-
After the package installation finishes, run
mssql-conf setupand follow the prompts to set thesapassword and choose your edition. The following [!INCLUDE ssnoversion-md] editions are freely licensed: Evaluation, Developer, and Express.sudo /opt/mssql/bin/mssql-conf setup
[!CAUTION]
[!INCLUDE password-complexity] -
When the configuration is done, verify that the service is running:
systemctl status mssql-server --no-pager
-
If you plan to connect remotely, you might also need to open the [!INCLUDE ssnoversion-md] TCP port (default 1433) on your firewall.
At this point, [!INCLUDE ssnoversion-md] is running on your Ubuntu machine and is ready to use.
::: moniker-end
[!INCLUDE connect-with-sa]
To create a database, you need to connect with a tool that can run Transact-SQL statements on [!INCLUDE ssnoversion-md]. The following steps install the [!INCLUDE ssnoversion-md] command-line tools: sqlcmd utility and bcp utility.
[!INCLUDE odbc-ubuntu]
[!INCLUDE Connect, create, and query data]