Table of Contents
SQL Server runs natively on supported Ubuntu releases. This guide installs SQL Server 2025 on Ubuntu 24.04 or 22.04, configures the service, adds the current command-line tools, and verifies the installation with a test database.
Microsoft supports Ubuntu 24.04 starting with SQL Server 2025 CU 1 and Ubuntu 22.04 for SQL Server 2025. Check the current Microsoft installation matrix before using these commands because the repository must match both the Ubuntu and SQL Server versions.
Before you install
- Use an Intel or AMD x86-64 system; Microsoft does not support SQL Server Linux packages through CPU emulation.
- Allocate at least 2 GB of memory for installation, with additional memory, CPU, and storage sized for the workload.
- Use a currently supported Ubuntu release and install available security updates.
- Choose the SQL Server edition and review its license before production use. Developer edition is for development and testing, not production.
Confirm the operating-system version and architecture:
lsb_release -rs
uname -m
1. Add the Microsoft SQL Server repository
Install the tools required to add the signing key:
sudo apt-get update
sudo apt-get install -y curl gnupg
Download and store Microsoft’s repository key:
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
On Ubuntu 24.04, register the SQL Server 2025 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
On Ubuntu 22.04, use the matching path instead:
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
Run only the command for your installed Ubuntu release. Do not reuse an older 16.04 repository or the deprecated apt-key workflow.
2. Install and configure SQL Server
sudo apt-get update
sudo apt-get install -y mssql-server
sudo /opt/mssql/bin/mssql-conf setup
The setup asks you to select an edition, accept the license terms, and create the initial sa password. Use a long, unique password that meets the displayed policy and store it in an approved password manager.
Check that the service is active:
systemctl status mssql-server --no-pager
If it failed to start, inspect recent logs before changing the configuration:
sudo journalctl -u mssql-server -n 100 --no-pager
3. Install sqlcmd and bcp
For Ubuntu 24.04, install Microsoft’s repository package, then the current mssql-tools18 package:
curl -sSL -O https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y mssql-tools18 unixodbc-dev
On Ubuntu 22.04, use the matching 22.04 repository package or follow Microsoft’s current sqlcmd installation instructions.
Add the tools to the Bash path:
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc
4. Connect and create a test database
Connect locally and enter the password when prompted so it is not stored in shell history:
sqlcmd -S localhost -U sa
At the 1> prompt, create a database and list the databases:
CREATE DATABASE TestDB;
GO
SELECT name FROM sys.databases ORDER BY name;
GO
Type QUIT to end the session. If the connection fails, check the service status, server logs, credentials, and the encryption-related message before weakening any client security setting.
5. Allow remote connections only when needed
Local connections do not require a firewall rule. For a remote client, permit TCP 1433 only from a trusted address or subnet rather than exposing it to the entire internet:
sudo ufw allow from <trusted-client-ip> to any port 1433 proto tcp
sudo ufw status
Also restrict the port with a cloud security group or network firewall. Prefer a VPN or private network, keep SQL Server patched, and never publish sa credentials in an application configuration file.
Secure the administrator account
After the first connection, create a named administrative login or configure Active Directory authentication, verify that it works, and disable sa when it is not required. If access is ever lost, follow the supported recovery method in TipsMake’s SQL Server administrator recovery guide rather than modifying master.mdf.
To understand how SQL Server differs from other data stores, see this SQL and NoSQL overview.
Reader Comments 0
Sign in with email or Google to join the discussion.