Microsoft SQL Server is one of the most powerful and popular database platforms for Windows, which is now also supported by Linux. This makes it a cross-platform database that allows developers, database administrators, and businesses to run SQL scripts efficiently that best fits their needs.
Running SQL server on Linux opens up a sea of opportunities for mixed-OS infrastructures in cloud-native deployments and integrations with container technologies like Docker and Kubernetes.
In this guide, we will walk through the installation guide, configurations, and SQL Server management on Linux distributions with troubleshooting tips.
Why Use SQL Server on Linux?
SQL Server on Linux offers multiple enterprise-level performance, security, and features same as on Windows. Other important benefits include:
- Cross-platform flexibility – you can use SQL Server with mixed-OS infrastructures without Windows.
- Lower costs – you can avoid Windows licensing fees with Linux’s open-source ecosystem.
- Cloud and container readiness – Run SQL Server with container tools like Docker and Kubernetes.
- Performance & Stability – benefit from Linux’s lightweight nature and robust performance in server environments.
- Developer friendly – Integrate with Linux-based development tools and CI/CD pipelines.
Supported Linux Distributions for SQL Server
Microsoft officially supports SQL Server on several major Linux distributions:
- Ubuntu (16.04, 18.04, 20.04, 22.04)
- Debian (9, 10, 11)
- Red Hat Enterprise Linux (RHEL) (7, 8, 9)
- CentOS (7, 8) (CentOS Stream supported for some versions)
- Fedora (latest supported releases)
- SUSE Linux Enterprise Server (SLES) (12 SP3+, 15+)
- Amazon Linux 2 (with some limitations)
Prerequisites for Installing SQL Server on Linux
Prepare your system by completing the following requirements to run SQL Server on Linux.
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
- Check for supported OS versions.
- Sufficient system resources:
- Memory: Minimum 2 GB RAM (4 GB+ recommended)
- Disk space: At least 6 GB free for installation
- Processor: x64 processor with at least 2 cores
- Ensure that you have root or sudo privileges.
- Stable internet connection.
- Firewall configuration – Open TCP port 1433 for SQL Server connections if remote access is required.
Installing SQL Server on Different Linux Distros
Microsoft offers official packages and repositories for most of the popular Linux distributions, which makes SQL Server installation easy. Here are the installation steps that you can follow:
Installing SQL Server on Ubuntu/Debian
- Import Microsoft GPG keys
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –
- Register the Microsoft repository
sudo add-apt-repository “$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)”
(Replace 20.04 to match your supported Ubuntu version.)
- Update package lists and install SQL Server
sudo apt-get update
sudo apt-get install -y mssql-server
- Run the setup wizard
sudo /opt/mssql/bin/mssql-conf setup
Follow the prompts to set your edition and password.
Installing SQL Server on RHEL/Fedora
- Import Microsoft GPG keys
sudo rpm –import https://packages.microsoft.com/keys/microsoft.asc
- Add the Microsoft repository
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo

- Install SQL Server
sudo yum install -y mssql-server
- Run the setup wizard
sudo /opt/mssql/bin/mssql-conf setup
Installing SQL Server on Amazon Linux 2
- Import Microsoft GPG keys
sudo rpm –import https://packages.microsoft.com/keys/microsoft.asc
- Add the repository
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/amazon/2/mssql-server-2019.repo
- Install SQL Server
sudo yum install -y mssql-server
- Run the setup wizard
sudo /opt/mssql/bin/mssql-conf setup
Installing SQL Server on SUSE Linux Enterprise
- Import Microsoft GPG keys
sudo rpm –import https://packages.microsoft.com/keys/microsoft.asc
- Add the Microsoft repository
sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/15/mssql-server-2019.repo
- Install SQL Server
sudo zypper install -y mssql-server
- Run the setup wizard
sudo /opt/mssql/bin/mssql-conf setup
Configuring SQL Server on Linux
After you have successfully installed SQL Server on Linux machines, you need to set proper configurations. The primary configuration tool is mssql-conf.
- Run the setup tool by using the command line: sudo /opt/mssql/bin/mssql-conf setup
- Select your preferred SQL Server edition from Evaluation, Developer, Express, and others.
- Accept the licensing terms.
- Set the system administrator password.
- Enable the SQL Server to start on boot by running: sudo systemctl enable mssql-server
- Check SQL Server status by running: systemctl status mssql-server
Connecting to SQL Server from the Command Line
To connect SQL Server on Linux, you can also use Microsoft’s command-line tool sqlcmd.
- Install sqlcmd:
For Ubuntu/Debian:
sudo apt-get install -y mssql-tools unixodbc-dev
For RHEL/ Fedora
sudo yum install -y mssql-tools unixODBC-devel
- Connect to SQL Server:
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ‘YourPassword’
- Run a quick query:
SELECT @@VERSION;
GO
This will show the SQL Server version and other platform details.
Managing SQL Server Services on Linux
Managing SQL Server on Linux is pretty easy, just like any other systemd service.
- Start SQL Server:
sudo systemctl start mssql-server
- Stop SQL Server:
sudo systemctl stop mssql-server
- Restart SQL Server:
sudo systemctl restart mssql-server
- Check SQL Server status:
systemctl status mssql-server
Updating and Uninstalling SQL Server on Linux
Updating SQL Server
Ensure that you regularly update SQL server for a secure and stable connection using your distro’s package manager.
- Ubuntu/Debian
sudo apt-get update
sudo apt-get install mssql-server
- RHEL/Fedora/Amazon Linux
sudo yum update mssql-server
- SUSE
sudo zypper refresh
sudo zypper update mssql-server
After updating, restart the service:
sudo systemctl restart mssql-server
Uninstalling SQL Server
- Ubuntu/Debian
sudo apt-get remove mssql-server
sudo apt-get autoremove
- RHEL/CentOS/Fedora/Amazon Linux
sudo yum remove mssql-server
- SUSE
sudo zypper remove mssql-server
If you also want to delete databases and configuration files, remove /var/opt/mssql/.
Common Issues and Troubleshooting
Issue | Possible Cause | Solution |
SQL Server service won’t start | Incorrect configuration or low memory | Check logs at /var/opt/mssql/log/errorlog and verify the system meets minimum requirements. |
Cannot connect using sqlcmd | Firewall blocking port 1433 | Open port using sudo ufw allows 1433/tcp or equivalent for your distro. |
sa login fails | Wrong password or disabled account | Reset password with sudo /opt/mssql/bin/mssql-conf set-sa-password. |
Installation fails | Missing dependencies | Update package lists and install missing packages before retrying. |
Slow performance | Insufficient system resources | Increase RAM, CPU allocation, or optimize queries. |
Conclusion
Running SQL scripts on Linux gives you the freedom to combine Microsoft’s robust database technology with the stability of Linux. So no matter if you are deploying on-premises, cloud, or in containers, the installation and management process is pretty simple!
FAQs
Which Linux distributions support SQL Server?
SQL Server is supported on Ubuntu, Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), and Docker containers.
Is SQL Server on Linux the same as on Windows?
The core engine is the same, but some Windows-only features (like SQL Server Reporting Services) may not be available on Linux.
Is performance different on Linux vs Windows for SQL Server?
Performance is comparable; in some cases, Linux provides better efficiency depending on system resources and workloads.