Getting Started with SQL Server on Linux

sql server on linux

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

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:

Prerequisites for Installing SQL Server on Linux

Prepare your system by completing the following requirements to run SQL Server on Linux. 

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

  1. Check for supported OS versions. 
  2. 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
  3. Ensure that you have root or sudo privileges.
  4. Stable internet connection. 
  5. 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

  1. Import Microsoft GPG keys

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –

  1. 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.)

  1. Update package lists and install SQL Server

sudo apt-get update

sudo apt-get install -y mssql-server

  1. 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

  1. Import Microsoft GPG keys

sudo rpm –import https://packages.microsoft.com/keys/microsoft.asc

  1. 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

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

  1. Install SQL Server

sudo yum install -y mssql-server

  1. Run the setup wizard

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

Installing SQL Server on Amazon Linux 2

  1. Import Microsoft GPG keys

sudo rpm –import https://packages.microsoft.com/keys/microsoft.asc

  1. Add the repository

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/amazon/2/mssql-server-2019.repo

  1. Install SQL Server

sudo yum install -y mssql-server

  1. Run the setup wizard

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

Installing SQL Server on SUSE Linux Enterprise

  1. Import Microsoft GPG keys

sudo rpm –import https://packages.microsoft.com/keys/microsoft.asc

  1. Add the Microsoft repository

sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/15/mssql-server-2019.repo

  1. Install SQL Server

sudo zypper install -y mssql-server

  1. 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.

  1. Run the setup tool by using the command line: sudo /opt/mssql/bin/mssql-conf setup
  2. Select your preferred SQL Server edition from Evaluation, Developer, Express, and others. 
  3. Accept the licensing terms. 
  4. Set the system administrator password. 
  5. Enable the SQL Server to start on boot by running: sudo systemctl enable mssql-server
  6. 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.

  1. 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

  1. Connect to SQL Server:

/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ‘YourPassword’

  1. 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

IssuePossible CauseSolution
SQL Server service won’t startIncorrect configuration or low memoryCheck logs at /var/opt/mssql/log/errorlog and verify the system meets minimum requirements.
Cannot connect using sqlcmdFirewall blocking port 1433Open port using sudo ufw allows 1433/tcp or equivalent for your distro.
sa login failsWrong password or disabled accountReset password with sudo /opt/mssql/bin/mssql-conf set-sa-password.
Installation failsMissing dependenciesUpdate package lists and install missing packages before retrying.
Slow performanceInsufficient system resourcesIncrease 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.

Marium Fahim
Hi! I am Marium, and I am a full-time content marketer fueled by an iced coffee. I mainly write about tech, and I absolutely love doing opinion-based pieces. Hit me up at [email protected].
Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!