1080*80 ad

Installing Microsoft SQL Server 2017 on Fedora 29 and CentOS 7

How to Install SQL Server 2017 on CentOS 7 and Fedora 29: A Complete Guide

Microsoft SQL Server, once exclusive to the Windows ecosystem, is now a powerful, cross-platform database solution available on Linux. This guide provides a detailed, step-by-step walkthrough for installing SQL Server 2017 on two popular RPM-based distributions: CentOS 7 and Fedora 29.

While the process is straightforward for the officially supported CentOS 7, installing on Fedora requires a specific workaround due to package dependencies. Follow along to get your enterprise-grade database up and running.

Prerequisites

Before you begin, ensure your system meets the following minimum requirements:

  • At least 2 GB of RAM.
  • A user account with sudo privileges.
  • A stable internet connection to download the necessary packages.

Installing SQL Server 2017 on CentOS 7

CentOS 7 is an officially supported platform for SQL Server, making the installation process smooth and reliable.

Step 1: Add the Microsoft SQL Server Repository

First, you need to add the Microsoft SQL Server 2017 repository to your system’s package manager. This allows yum to locate and install the required software.

Open your terminal and run the following command:

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

Step 2: Install the SQL Server Package

With the repository configured, you can now install the main mssql-server package. This command will download and install the database engine.

sudo yum install -y mssql-server

Step 3: Configure SQL Server

After the installation is complete, you must run the configuration script. This script allows you to select your desired SQL Server edition (the free Developer edition is an excellent choice for non-production environments) and set a strong password for the System Administrator (SA) account.

Run the setup utility with this command:

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

Follow the on-screen prompts. Be sure to choose a secure and memorable password for the SA account, as you will need it to connect to the database.

Step 4: Verify the Service is Running

Once the configuration is finished, the SQL Server service should start automatically. You can verify its status to ensure everything is working correctly.

systemctl status mssql-server

You should see an “active (running)” status in the output, indicating a successful installation.

Installing SQL Server 2017 on Fedora 29 (with Workaround)

Fedora is not officially supported by Microsoft for this version of SQL Server. The primary issue is a dependency on an older version of OpenSSL. However, you can work around this by installing a compatibility package.

Important: This method relies on packages intended for RHEL/CentOS and is not officially supported. Proceed with caution, especially in production environments.

Step 1: Install the Compatibility OpenSSL Package

The key to installing on Fedora 29 is to first install the compat-openssl10 package. This provides the specific OpenSSL library that SQL Server depends on.

sudo dnf install compat-openssl10

Step 2: Add the RHEL 7 Repository

Next, add the repository for Red Hat Enterprise Linux 7, which is compatible with our setup.

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

Step 3: Install and Configure SQL Server

Now, the process becomes identical to the CentOS installation. Install the mssql-server package and run the configuration script.

sudo dnf install -y mssql-server
sudo /opt/mssql/bin/mssql-conf setup

Again, choose your edition and set a strong SA password when prompted. After setup, verify the service is active:

systemctl status mssql-server

Installing SQL Server Command-Line Tools (For Both Systems)

To interact with your new SQL Server instance, you need to install the command-line tools, including sqlcmd and bcp.

Step 1: Add the Microsoft Tools Repository

First, add the repository containing the command-line tools.

sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo

Step 2: Install the Tools

Install the mssql-tools and the required UnixODBC developer package. Accept the license terms when prompted.

# Use yum for CentOS, dnf for Fedora
sudo yum install -y mssql-tools unixODBC-devel
# Or for Fedora:
# sudo dnf install -y mssql-tools unixODBC-devel

Step 3: Add Tools to Your PATH

For convenient access, add the tools directory to your PATH environment variable. This ensures you can run sqlcmd from any location in your terminal.

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

Connecting to Your Local SQL Server Instance

With the tools installed, you can now test the connection to your local database. Use the sqlcmd utility with the server name (localhost), the SA username, and the password you created during setup.

sqlcmd -S localhost -U SA -P 'YourStrongPassword'

If the connection is successful, you will see a 1> prompt. You can run a simple query to confirm:

SELECT @@VERSION;
GO

Type QUIT to exit the sqlcmd prompt.

Security Tip: Configure Your Firewall for Remote Access

By default, your server’s firewall will likely block external connections to SQL Server. To allow remote access, you must open the default SQL Server port, TCP 1433.

Use the firewall-cmd utility to create a permanent rule and apply it.

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

This command opens port 1433, making your SQL Server instance accessible from other machines on the network. Only open this port if you require remote access, and ensure your network is secure.

You have now successfully installed and configured Microsoft SQL Server 2017 on your Linux system. You can begin migrating databases, developing applications, or connecting with management tools like Azure Data Studio.

Source: https://kifarunix.com/install-microsoft-sql-server-2017-on-fedora-29-centos-7/

900*80 ad

      1080*80 ad