How to Install SQL Server on CentOS 8

SQL Server is a relational database management system (RDBMS) developed by Microsoft. Since 2017, Microsoft has released SQL Server for the Linux distributions Red Hat, SUSE, Ubuntu, and Docker. In this tutorial we will install SQL Server on CentOS 8.

*System requirements*

SQL Server has the following system requirements for Linux:

· RAM 2GB · File System XFS/EXT4 · Disk Space 6GB · CPU speed 2GHz · CPU core 2 cores · CPU type x64

*Install SQL Server 2019*

SQL Server 2019 requires *python2*, while on CentOS 8 python2 is no longer available by default.

Install python2 and compat-openssl10.


1 sudo dnf install python2 compat-openssl10 -y

Configure python2 as the default interpreter.


1 sudo alternatives –config python

Enter *2* for python2.


1 2 3 4 5 6 7 8 There are 2 programs which provide ‘python’.     Selection    Command ———————————————– *+ 1           /usr/libexec/no-python    2           /usr/bin/python2   Enter to keep the current selection[+], or type selection number: 2

Download the SQL Server 2019 repository configuration file.


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

Install SQL Server.


1 sudo dnf install mssql-server -y

Run *myssql-conf setup* to provide a password for the *SA* account and select the SQL Server edition.


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

Choosing the SQL Server edition, I chose *2) Developer*.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Choose an edition of SQL Server:   1) Evaluation (free, no production use rights, 180-day limit)   2) Developer (free, no production use rights)   3) Express (free)   4) Web (PAID)   5) Standard (PAID)   6) Enterprise (PAID) – CPU Core utilization restricted to 20 physical/40 hyperthreaded   7) Enterprise Core (PAID) – CPU Core utilization up to Operating System Maximum   8) I bought a license through a retail sales channel and have a product key to enter.   Details about editions can be found at   Use of PAID editions of this software requires separate licensing through a Microsoft Volume Licensing program. By choosing a PAID edition, you are verifying that you have the appropriate number of licenses in place to install and run this software.   Enter your edition(1-8): 2

Approved the license.


1 2 3 4 5 6 7 8 The license terms for this product can be found in /usr/share/doc/mssql-server or downloaded from:   The privacy statement can be viewed at:   Do you accept the license terms? [Yes/No]:Yes

Provide a password for the SQL Server system administrator (SA) account. The password must be at least 8 characters long and contain characters from three of the following four sets: uppercase letters, lowercase letters, numbers, and symbols.


1 Enter the SQL Server system administrator password:

Memeriksa status *mssql-server* service.


1 sudo systemctl status mssql-server

In order to get a remote connection, open the SQL Server port in FirewallD.


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

*Install SQL Server command-line tools*

Install the SQL Server command-line tools, *sqlcmd* and *bcp*.

Download repository configuration file.


1 sudo curl -o /etc/yum.repos.d/msprod.repo

Install mssql-tools.


1 sudo yum install -y mssql-tools unixODBC-devel -y

Add */opt/mssql-tools/bin/* into your PATH environment variable.


1 2 3 echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bash_profile echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bashrc source ~/.bashrc


Testing is done by logging into SQL Server, creating a database, and inserting data.

-Login to SQL Server-

Login to SQL Server using sqlcmd. Enter the system administrator password that has been created.


1 sqlcmd -S localhost -U SA

-Create a Database-

Create a TestDB database.



The command above has not been executed, type *GO* to execute the previous command.


1 GO

Displays all databases on the server.


1 2 SELECT Name from sys.Databases GO

Login & create database

-Insert Data-

Next create a table and enter two rows of data.

Switch to TestDB.


1 USE TestDB

Create a table with the name Inventory.


1 CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT)

Insert data into tables.


1 INSERT INTO Inventory VALUES (1, ‘banana’, 150); INSERT INTO Inventory VALUES (2, ‘orange’, 154);

Finally type GO to execute the previous command.


1 GO

Create table & insert data

-Selecting Data-

Select and display data from the Inventory table.


1 2 SELECT * FROM Inventory WHERE quantity > 152 GO

Select data

-Exit sqlcmd-

To exit sqlcmd type QUIT.



Good luck 🙂

Leave a Reply

Your email address will not be published.