search
HomeSystem TutorialLINUXHow to Install and Configure SQL Server on RHEL

This tutorial guides you through installing SQL Server 2022 on RHEL 8.x or 9.x, connecting via the sqlcmd command-line tool, database creation, and basic querying.

Prerequisites

Before beginning, ensure:

  • A supported RHEL version (RHEL 8 or 9).
  • Sudo or root privileges.
  • At least 2 GB RAM, 6 GB free disk space, and a supported x64 CPU architecture.

SQL Server 2022 supports RHEL 8.x and 9.x. For RHEL 9, running SQL Server as a confined application using SELinux (Security-Enhanced Linux) is recommended for enhanced security.

Enable SELinux enforcement (optional for RHEL 8, recommended for RHEL 9):

sestatus
sudo setenforce 1

If SELinux is disabled in /etc/selinux/config, sudo setenforce 1 will fail. You'll need to modify /etc/selinux/config to set SELINUX=enforcing and reboot.

Edit /etc/selinux/config:

sudo vi /etc/selinux/config

Change SELINUX=disabled to SELINUX=enforcing.

How to Install and Configure SQL Server on RHEL

Reboot your system:

sudo reboot

Verify SELinux is in Enforcing mode:

getenforce

The output should be Enforcing.

Step 2: Installing SQL Server on RHEL

Download and configure the Microsoft SQL Server repository:

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/$(rpm -E %{rhel})/mssql-server-2022.repo

Install the SQL Server package:

sudo yum install -y mssql-server

How to Install and Configure SQL Server on RHEL

For enhanced security with SELinux, install:

sudo yum install -y mssql-server-selinux

Run the setup script, setting the 'sa' password and choosing your SQL Server edition (Evaluation, Developer, or Express are free):

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

How to Install and Configure SQL Server on RHEL

Verify SQL Server is running:

sudo systemctl status mssql-server

How to Install and Configure SQL Server on RHEL

Start it if necessary:

sudo systemctl start mssql-server

Open port 1433 (default SQL Server port) in FirewallD:

sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
sudo firewall-cmd --reload

Step 3: Installing SQL Server Command-Line Tools

Install sqlcmd and bcp:

Download the Microsoft Red Hat repository configuration file (use the command appropriate for your RHEL version):

RHEL 9:

curl https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo

RHEL 8:

curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo

Install the tools and unixODBC:

sudo yum install -y mssql-tools18 unixODBC-devel

How to Install and Configure SQL Server on RHEL

Update to the latest version:

sudo yum check-update
sudo yum update mssql-tools18

Add sqlcmd and bcp to your PATH (choose one method):

For current session only:

export PATH="$PATH:/opt/mssql-tools18/bin"

To persist across sessions (recommended): Edit ~/.bashrc or ~/.bash_profile:

echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc

Step 4: Connecting to and Using SQL Server

Connect locally using sqlcmd:

sqlcmd -S localhost -U sa -P '<your_sa_password>' -N -C</your_sa_password>

Create a database:

CREATE DATABASE TestDB;
GO

List databases:

SELECT Name FROM sys.databases;
GO

Create and populate a table:

USE TestDB;
GO
CREATE TABLE dbo.Inventory (id INT, name NVARCHAR(50), quantity INT, PRIMARY KEY (id));
GO
INSERT INTO dbo.Inventory VALUES (1, 'banana', 150), (2, 'orange', 154);
GO

Query the table:

SELECT * FROM dbo.Inventory WHERE quantity > 152;
GO

How to Install and Configure SQL Server on RHEL

Exit sqlcmd:

QUIT

Alternative tools include Azure Data Studio, Visual Studio Code (with the mssql extension), PowerShell Core, and mssql-cli.

Conclusion

This guide detailed installing SQL Server 2022 on RHEL, configuration, database creation, and basic querying using sqlcmd.

The above is the detailed content of How to Install and Configure SQL Server on RHEL. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does the command line environment of Linux make it more/less secure than Windows?How does the command line environment of Linux make it more/less secure than Windows?May 01, 2025 am 12:03 AM

Linux'scommandlinecanbemoresecurethanWindowsifmanagedcorrectly,butrequiresmoreuserknowledge.1)Linux'sopen-sourcenatureallowsforquicksecurityupdates.2)Misconfigurationcanleadtovulnerabilities.Windows'commandlineismorecontrolledbutlesscustomizable,with

How to Make a USB Drive Mount Automatically in LinuxHow to Make a USB Drive Mount Automatically in LinuxApr 30, 2025 am 10:04 AM

This guide explains how to automatically mount a USB drive on boot in Linux, saving you time and effort. Step 1: Identify Your USB Drive Use the lsblk command to list all block devices. Your USB drive will likely be labeled /dev/sdb1, /dev/sdc1, etc

Best Cross-Platform Apps for Linux, Windows, and Mac in 2025Best Cross-Platform Apps for Linux, Windows, and Mac in 2025Apr 30, 2025 am 09:57 AM

Cross-platform applications have revolutionized software development, enabling seamless functionality across operating systems like Linux, Windows, and macOS. This eliminates the need to switch apps based on your device, offering consistent experien

Best Linux Tools for AI and Machine Learning in 2025Best Linux Tools for AI and Machine Learning in 2025Apr 30, 2025 am 09:44 AM

Artificial Intelligence (AI) is rapidly transforming numerous sectors, from healthcare and finance to creative fields like art and music. Linux, with its open-source nature, adaptability, and performance capabilities, has emerged as a premier platfo

5 Best Lightweight Linux Distros Without a GUI5 Best Lightweight Linux Distros Without a GUIApr 30, 2025 am 09:38 AM

Looking for a fast, minimal, and efficient Linux distribution without a graphical user interface (GUI)? Lightweight, GUI-less Linux distros are perfect for older hardware or specialized tasks like servers and embedded systems. They consume fewer res

How to Install Wine 10.0 in RedHat DistributionsHow to Install Wine 10.0 in RedHat DistributionsApr 30, 2025 am 09:32 AM

Wine 10.0 stable version release: Running Windows applications on Linux to a higher level Wine, this open source and free application, allows Linux users to run Windows software and games on Unix/Linux operating systems, ushering in the release of the 10.0 stable version! This version has been provided with source code and binary package downloads, and supports various distributions such as Linux, Windows and Mac. This edition embodies a year of hard work and over 8,600 improvements, bringing many exciting improvements. Key highlights include: Enhanced support for Bluetooth devices. Improve support for HID input devices. Optimized performance of 32-bit and 64-bit applications.

How to Install and Configure SQL Server on RHELHow to Install and Configure SQL Server on RHELApr 30, 2025 am 09:27 AM

This tutorial guides you through installing SQL Server 2022 on RHEL 8.x or 9.x, connecting via the sqlcmd command-line tool, database creation, and basic querying. Prerequisites Before beginning, ensure: A supported RHEL version (RHEL 8 or 9). Sudo

How to Install Thunderbird 135 on a Linux DesktopHow to Install Thunderbird 135 on a Linux DesktopApr 30, 2025 am 09:26 AM

Mozilla Thunderbird 135: Powerful cross-platform mail client Mozilla Thunderbird is a free, open source, cross-platform email, calendar, news, chat and contact management client designed to efficiently handle multiple email accounts and news sources. On February 5, 2025, Mozilla released the Thunderbird 135 version, introducing a number of new features, performance improvements and security fixes. Thunderbird 135 main features: XZ Packaging for Linux Binaries: Smaller files, faster unpacking, and better integration with modern distributions. Cookie storage support: when creating space

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.