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
sudo
privileges - 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-manager
tool)
Step 1: Register RHEL and Enable Repositories
Make sure your system is registered:
sudo subscription-manager register
Then attach the subscription:
sudo subscription-manager attach --auto
Enable 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-rpms
Step 2: Import the Microsoft GPG Key
Run the following to add Microsoft’s GPG key:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
Step 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.repo
For 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-server
After installation, run the setup utility:
sudo /opt/mssql/bin/mssql-conf setup
You’ll be prompted to choose the edition, accept the license terms, and set the sa
password.
Start the service:
sudo systemctl enable --now mssql-server
Step 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 --reload
Step 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.repo
Then install:
sudo dnf install -y mssql-tools unixODBC-devel
Add tools to your path by editing .bashrc
or .bash_profile
:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
source ~/.bash_profile
Step 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;
GO
Final 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.
Leave a Reply