Introduction
Microsoft’s decision to extend SQL Server to the Linux platform marks a significant shift in its strategy, acknowledging Linux as a vital player in enterprise environments. This move has broadened SQL Server’s audience and provided more deployment flexibility for organizations. Today, we will explore how to install and configure SQL Server on a Red Hat Enterprise Linux (RHEL) 9 host.
Why SQL Server on Linux?
The demand for high-performance, secure, and reliable database systems is prevalent in many enterprise settings, and Linux is a popular choice due to its stability and performance. By offering SQL Server on Linux, Microsoft provides businesses with the opportunity to leverage SQL Server’s capabilities on their preferred operating system.
Features Not Available on Linux
While SQL Server on Linux offers a comprehensive set of features, certain capabilities such as Reporting Services and Analysis Services remain exclusive to the Windows environment. It’s essential to be aware of these limitations when considering SQL Server for Linux. For a detailed list of features not available on Linux, refer to Microsoft’s official documentation.
Choosing Between Red Hat and Ubuntu Server for SQL Server on Linux
When deciding between Red Hat and Ubuntu Server for hosting SQL Server on Linux, consider the following factors:
Red Hat Enterprise Linux (RHEL)
- Enterprise Support: RHEL offers extensive commercial support, making it a preferred choice for large enterprises that require robust, professional assistance.
- Stability and Security: Known for its stability and security, RHEL is designed for enterprise environments where reliability is crucial.
- Ecosystem Integration: RHEL integrates well with other enterprise solutions from Red Hat, offering a comprehensive ecosystem for IT operations.
- Cost: RHEL is a subscription-based OS, which can be a consideration for budget-conscious organizations.
Ubuntu Server
- Ease of Use: Ubuntu Server is known for its user-friendly nature, making it easier for newcomers to Linux to get started.
- Community Support: Ubuntu has a strong community support network, which can be beneficial for troubleshooting and finding resources.
- Cost: Ubuntu Server is free and open-source, which can be a significant advantage for smaller businesses or those looking to reduce costs.
- Flexibility: It is versatile and can be used in various environments, from development to production.
Choosing between Red Hat and Ubuntu Server depends on your specific needs. If you prioritize enterprise-level support, stability, and security, RHEL is a strong choice. On the other hand, if ease of use, community support, and cost are more critical, Ubuntu Server might be the better option.
This post is a tutorial for installing SQL Server on Red Hat Enterprise Linux 9. If you would prefer to use Ubuntu instead of Red Hat, please follow my Ubuntu tutorial here.
Installing SQL Server on Red Hat 9
Red Hat Enterprise Linux (RHEL) is a widely used and stable Linux distribution for enterprise server environments. Here’s how you can install SQL Server on Red Hat 9:
- Add Microsoft’s Repository:
sudo su curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/9/mssql-server-2022.repo exit
- Update the package list:
sudo dnf update
- Install SQL Server:
sudo dnf install -y mssql-server
- Configure SQL Server:
sudo /opt/mssql/bin/mssql-conf setup
- Start SQL Server:
sudo systemctl start mssql-server
Installing SQL Server Tools on Red Hat 9
To effectively manage and interact with SQL Server on Red Hat 9, you’ll need to install the SQL Server tools. These tools include command-line utilities and graphical interfaces that simplify database administration and development tasks.
- Install the SQL Server Command-Line Tools (sqlcmd and bcp):
sudo su curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/9/prod.repo exit
- Update the package list and install the tools and the UNIX ODBC driver:
sudo dnf update -y && sudo dnf install -y mssql-tools unixODBC-devel
- Add the SQL Server Tools to Your PATH:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bash_profile
Basic SQL Server Configuration on Linux
Once installed, there are several configuration settings you can adjust to optimize SQL Server for your environment. SQL Server will need to be restarted for any configuration changes to take effect. Here are a few examples:
- Enabling the SQL Server Agent:
sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true
- Configuring SQL Server Max Memory to 16GB:
sudo /opt/mssql/bin/mssql-conf set memory.memorylimitmb 16000
- Adjusting Worker Threads:
sudo /opt/mssql/bin/mssql-conf set hadr.num_worker_threads 300
- Restart for configuration changes to take effect:
sudo systemctl restart mssql-server
Connecting to SQL Server using sqlcmd
Once you have SQL Server and the SQL Server tools installed on your Red Hat 9 system, you can use the command-line tool sqlcmd
to connect to SQL Server and execute SQL queries. Here’s how:
- Open your terminal:Launch your terminal on Red Hat 9.
- Connect to SQL Server:Use the following command to connect to SQL Server. Replace
<username>
and<password>
with your SQL Server credentials:sqlcmd -S localhost -U <username> -P <password>
- Execute SQL Queries:Once connected, you can execute SQL queries directly from the command line. For example:
SELECT * FROM your_table;
- Exit sqlcmd:To exit sqlcmd, simply type:
QUIT
Using sqlcmd is a convenient way to interact with your SQL Server database from the command line on Red Hat Linux.
Conclusion
The integration of SQL Server with Linux exemplifies the industry’s move towards flexibility and choice. With SQL Server on Linux, businesses have another robust option for their database management needs. SQL Server is an excellent enterprise database management system on both Windows and Linux platforms. Combining SQL Server and RHEL offers a robust, performant, and secure environment you can trust to keep your data safe and accessible.
what is username for login ?
The username for the administrative account created during initial configuration is ‘sa’. This is similar to the SQL Server authenticated ‘sa’ account on Windows.