Install Microsoft SQL Server 2019 on Linux - CentOS

This post explains how to install Microsoft SQL Server 2019 on CentOS (Linux). CentOS is an Enterprise-class Linux Distribution derived from sources freely provided to the public by Red Harm Inc. for Red Hat Enterprise Linux.

Requirement for MSSQL Installation

  • At least 2 GB of memory to run SQL Server on Linux 
  • The file system must be XFS or EXT4. 
  • Need administrative access for installation.
  • Requires user input and an internet connection.
To download Centos 7 on a machine, go to Download CentOS 7 package. My system is Centos 7 so I am selecting 7. Perform the following steps in a terminal windows to install the mssql-server package.

Configure repositories for SQL Server 2019

If necessary, remove the old repository with the following command.

sudo rm –rf /etc/yum.repos.d/mssql-server.repo

To install SQL Server on Linux, we need to configure Microsoft repository. This repository is used to acquire the database engine package, mssql-server, and related SQL Server packages.
This will download SQL Server 2019 repository to /etc/yum.repos.d/mssql-server.repo.

sudo curl -o /etc/yum.repos.d/mssql-server.repo

Updating System Cache

sudo yum makecache  # CentOS 7

Install MS SQL Server

To configure SQL Server on CentOS, run the following commands in a terminal to install the mssql-server package:
Run the following commands to install SQL Server:

sudo yum install -y mssql-server

Initialize MS SQL Database Engine

After the package installation finishes, run mssql-conf setup. mssql-conf is a configuration script that installs with SQL Server for Red Hat Enterprise Linux, SUSE Linux Enterprise Server, and Ubuntu.
Run the following command and follow the prompt to select an edition to use

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

Accept the license terms and set the SA password

Note: In case of failure refer to error log in /var/opt/mssql/log for more information.

Run the following commands to install mssql-tools

sudo yum install mssql-tools

Enable and restart SQL Server service

Enable and start sql server service on system boot

sudo systemctl enable mssql-server
sudo systemctl start mssql-server

For convenience, add /opt/mssql/bin/ to path environment variable. This will enable to run the tools without specifying the full path. Run the following commands to modify the PATH for both login sessions and interactive/non-login sessions.

echo 'export PATH=$PATH:/opt/mssql/bin' | sudo tee /etc/profile.d/
source /etc/profile.d/

Enable firewall rule

To allow remote connections, open the SQL Server port on the firewall. The default SQL Server port is TCP 1433. Use the following commands

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

Check MSSQL Services packages are installed

rpm -qa | grep mssql

Check MSSQL Services is running

Once the configuration is done, verify that the service is up and running.

systemctl status mssql-server

Login in SQL Server using sqlcmd

Check for last updated version

sudo yum check-update
sudo yum update mssql-server-agent
sudo yum update mssql-tools
sudo systemctl restart mssql-server

Check MSSQL process

ps -ef | grep mssql

Check package information of MSSQL

yum info mssql-server

No comments:

Post a Comment