How To Install Microsoft SQL Server on CentOS Stream 9
In this tutorial, we will show you how to install Microsoft SQL Server on CentOS Stream 9. Microsoft SQL Server is a powerful and widely used relational database management system that has long been a staple on Windows platforms. However, in recent years, Microsoft has made significant strides in making SQL Server available on Linux distributions, including CentOS Stream 9. Running SQL Server on CentOS Stream 9 offers numerous benefits, such as enhanced performance, cost savings, and the flexibility to run on open-source operating systems.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Microsoft SQL Server on CentOS Stream 9.
Prerequisites
- A server running one of the following operating systems: CentOS Stream 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection.
- You’ll need administrative privileges or root access on your CentOS Stream 9 system. If you don’t have them, reach out to your system administrator.
Install Microsoft SQL Server on CentOS Stream 9
Step 1. Before proceeding with the Kodi installation, it’s crucial to update your CentOS Stream 9 system to the latest versions of all packages. Log in to your account and switch to the root user using the su command. Run the following command to update your system:
sudo dnf clean all sudo dnf update
Step 2. Installing Microsoft SQL Server on CentOS Stream 9.
To install Microsoft SQL Server on CentOS Stream 9, you first need to add the official Microsoft repository to your system. This repository contains the packages required for SQL Server 2022. To add the repository, follow these steps:
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/9/mssql-server-2022.repo
Now that the repository is configured, you can install SQL Server using the dnf
package manager. Follow these steps:
sudo dnf install mssql-server
Step 3. Configure SQL Server.
After installing SQL Server, you need to run the mssql-conf
utility to configure the server and accept the license terms. Here’s how:
sudo /opt/mssql/bin/mssql-conf setup
The setup process will prompt you with a series of questions:
- Edition to install: Choose the desired edition of SQL Server. For non-production environments, the Developer edition is recommended. Other options include Evaluation, Express, Web, Standard, and Enterprise.
- Accept license terms: Review and accept the license terms for SQL Server.
- Set the system administrator (SA) password: Provide a strong password for the SA account, which is the primary administrative account for SQL Server.
After configuring SQL Server, it’s important to verify that the service is running correctly. You can check the status using the systemctl
command:
systemctl status mssql-server
To ensure that SQL Server starts automatically on system boot, run:
sudo systemctl start mssql-server sudo systemctl enable mssql-server
Step 4. Installing SQL Server Command Line Tools.
Microsoft provides a separate package called mssql-tools
that includes the sqlcmd
and bcp
utilities for working with SQL Server from the command line. To install these tools, follow these steps:
First, Add the Microsoft repository configuration for SQL tools by running the following command:
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/9/prod.repo
Install the mssql-tools
package along with the unixODBC-devel package using dnf
:
sudo dnf install mssql-tools unixODBC-devel
To make the tools accessible from anywhere in the terminal, add the /opt/mssql-tools/bin/
directory to your PATH environment variable. You can do this by modifying your shell profile file (e.g., ~/.bashrc
or ~/.bash_profile
).
Once installed, you can connect to your local SQL Server instance using the sqlcmd
utility. For example:
sqlcmd -S localhost -U SA -P 'YourPassword'
To test the installation, you can run a simple query such as SELECT @@VERSION;
to retrieve the version information of your SQL Server instance.
Step 5. Configure Remote Access.
By default, SQL Server listens on port 1433 and only allows local connections. To enable remote access to your SQL Server instance, you need to open the necessary port in the system firewall and configure SQL Server to listen on the network interface. Here’s how:
- Open port 1433 in the CentOS Stream 9 firewall using the firewall-cmd utility:
sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent sudo firewall-cmd --reload
- Configure SQL Server to listen on the network interface by modifying the
mssql.conf
file:
sudo /opt/mssql/bin/mssql-conf set network.tlsprotocols 1.2 sudo /opt/mssql/bin/mssql-conf set network.ipaddress 0.0.0.0 sudo systemctl restart mssql-server
- To connect remotely from another machine, you can use the
sqlcmd
utility with the appropriate connection details:
sqlcmd -S your_server_ip -U SA -P 'YourPassword'
Congratulations! You have successfully installed Microsoft SQL. Thanks for using this tutorial to install the Microsoft SQL Server on CentOS Stream 9. For additional help or useful information, we recommend you check the official Microsoft website.