Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

How to run SQL Server with SELinux enabled on RHEL 9

January 20, 2025
Vivien Wang Arne Arnold Amit Khandelwal (Microsoft)
Related topics:
DatabasesSecurityWindows
Related products:
Microsoft SQL Server on Red Hat Enterprise Linux

    Now you can run SQL Server 2025 as a confined application with pacemaker-enabled SELinux on Red Hat Enterprise Linux (RHEL). This article will demonstrate how to run SQL Server with SELinux enabled on RHEL 9.

    SELinux, enabled by default on RHEL 9, ensures enhanced security for your databases. SELinux is a Linux Security Model that defines access controls for applications, processes, and files on a system. It uses security policies, which are a set of rules that tell SELinux what can or cannot be accessed, to enforce the access allowed by a policy. SELinux is particularly valuable in containerized environments, adding an extra layer of isolation between containers and their host systems.

    Customers can run their SQL Server 2022 databases according to security best practices with the confidence that Microsoft and Red Hat fully support their configuration. You can try an SELinux-enabled operating system for free. To learn more about running SQL Server 2022 on RHEL 9, check out the article, Install SQL Server on RHEL 9.

    As of July 2024, SQL Server 2022 is officially certified with RHEL 9 and generally available on the Red Hat Ecosystem Catalog. 

    How to run SQL Server as a confined application

    To run SQL Server as a confined application, make sure SELinux is enabled and in enforcing mode. You can check this by running the following command:

    [ ~]$ sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: actual (secure) Max kernel policy version: 33

    To identify if the SQL Server service is currently running as confined or unconfined, you can run the command ps -eZ | grep sqlservr. If you see the type assigned as unconfined_service_t, it means this is running as unconfined.

    Install SQL Server as a confined service

    Running SQL Server as an unconfined application is the default mode. But you can still install and run SQL Server as an unconfined application as in previous versions of RHEL. In that case, installation of the mssql-server-selinux package is not necessary.

    Download the SQL Server 2022 (16.x) Red Hat 9 repository configuration file using this command:

    sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2022.repo

    Install the mssql-server package:

    sudo yum install -y mssql-server

    Next install the new mssql-server-selinux package:

    sudo yum install -y mssql-server-selinux

    After the package installation finishes, run mssql-conf setup using its full path. 

    Then follow the prompts to set the system administrator (SA) password and choose your edition as follows:

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

    Remember to specify a strong password for the SA account. You need a minimum length of 8 characters, including uppercase and lowercase letters, base-10 digits, and/or non-alphanumeric symbols.

    We strongly recommend using the SA account to log in for the first time. Users should then immediately disable the SA login as a security best practice. Read more about the SA account here. 

    You can verify that this setup is successful by running the following command:

    systemctl status mssql-server

    To allow remote connections, open the SQL Server port on the RHEL firewall. The default SQL Server port is TCP 1433. If you're using FirewallD for your firewall, run the following commands:

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

    You can verify that SQL Server is running unconfined using the following command:

    ps -eZ | grep sqlservr

    The output should be as follows:

    system_u:system_r:unconfined_service_t:s0 48265 ? 00:00:02 sqlservr

    Once you install the mssql-server-selinux package, this will enable a custom SELinux policy that confines the sqlservr process. When you install this policy, the selinuxuser_execmod Boolean is reset and replaced by a policy named mssql which confines the sqlservr process in the new mssql_server_t domain.

    Run this command:

    ps -eZ | grep sqlservr

    This should produce the following output:

    system_u:system_r:mssql_server_t:s0 48941 ?      00:00:02 sqlservr

    For more details refer to the article, Get Started With SQL Server on SELinux. 

    Configure SQL Server as a confined application

    You can run the following example playbook against a RHEL 9 system role to configure the SQL Server as a confined application:

    - hosts: all
      vars:
        mssql_accept_microsoft_odbc_driver_17_for_sql_server_eula: true
        mssql_accept_microsoft_cli_utilities_for_sql_server_eula: true
        mssql_accept_microsoft_sql_server_standard_eula: true
        mssql_version: 2022
        mssql_password: "p@55w0rD"
        mssql_edition: Evaluation
        mssql_run_selinux_confined: true
        mssql_manage_selinux: true

    Next steps

    To learn more about installing SQL Server on RHEL 9 and using SELinux, see Install SQL Server on RHEL 9 and Secure SQL Server on RHEL with SELinux. As previously mentioned, SQL Server supports this functionality only on RHEL 9, running the SQL Server version 2022 officially certified on RHEL 9. Feel free to reach out to your Red Hat contacts if you have questions.

    Last updated: January 27, 2025

    Related Posts

    • How SELinux improves Red Hat Enterprise Linux security

    • How custom SELinux policies secure servers and containers

    • What's new in Red Hat Enterprise Linux 9 (RHEL 9)

    • How the new RHEL 9.2 improves the developer experience

    • Active Directory Utility for SQL Server (ADUTIL) now officially supported with RHEL 9

    Recent Posts

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    What’s up next?

    Learn the basics of SELinux, including type enforcement, Multi-Category Security (MCS) Enforcement, and Multi-Level Security (MLS) Enforcement in this free e-book.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.