Your cart is currently empty!
How to Set Up SQL Server on Red Hat Enterprise Linux
Microsoft SQL Server isn’t just for Windows anymore. Thanks to Microsoft’s move toward Linux compatibility, you can now run SQL Server on Red Hat Enterprise Linux (RHEL) with full support. This guide walks you through the installation and setup process so you can get SQL Server up and running on your RHEL machine.
Prerequisites
Before diving in, make sure you have:
- A RHEL 8 (or 9) system with
sudoprivileges - A stable internet connection
- At least 2 GB of memory (4 GB recommended)
- A registered RHEL subscription (you can register via Red Hat Customer Portal or using the
subscription-managertool)
Step 1: Register RHEL and Enable Repositories
Make sure your system is registered:
sudo subscription-manager registerThen attach the subscription:
sudo subscription-manager attach --autoEnable the required repositories:
sudo subscription-manager repos --enable=rhel-8-for-x86_64-appstream-rpms
sudo subscription-manager repos --enable=rhel-8-for-x86_64-baseos-rpmsStep 2: Import the Microsoft GPG Key
Run the following to add Microsoft’s GPG key:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.ascStep 3: Add the Microsoft SQL Server Repository
Add the repo configuration:
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repoFor SQL Server 2022, just replace 2019 with 2022 in the URL.
Step 4: Install SQL Server
Now install SQL Server:
sudo dnf install -y mssql-serverAfter installation, run the setup utility:
sudo /opt/mssql/bin/mssql-conf setupYou’ll be prompted to choose the edition, accept the license terms, and set the sa password.
Start the service:
sudo systemctl enable --now mssql-serverStep 5: Open Firewall Port (Optional but Recommended)
By default, SQL Server listens on port 1433. Open it if you plan to connect remotely:
sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
sudo firewall-cmd --reloadStep 6: Install SQL Server Command-Line Tools (sqlcmd)
Add the repo for tools:
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repoThen install:
sudo dnf install -y mssql-tools unixODBC-develAdd tools to your path by editing .bashrc or .bash_profile:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
source ~/.bash_profileStep 7: Test the Installation
Use sqlcmd to connect and run a quick test:
sqlcmd -S localhost -U sa -P '<YourPassword>'Run a basic query to make sure everything’s working:
SELECT @@VERSION;
GOFinal Thoughts
SQL Server on RHEL is stable, performant, and works great in hybrid environments. With just a few commands, you can integrate Microsoft’s powerful database engine into your Linux-based infrastructure.
Keep your system updated and secure, and consider setting up automated backups and monitoring from day one.
Need help configuring your database for production workloads? Let me know in the comments or get in touch.

Tech enthusiast and content creator passionate about making technology simple for everyone. I share practical tips, guides, and reviews on the latest in computers, software, and gadgets. Let’s explore the digital world together!
