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.
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.
sudo dnf install python2 compat-openssl10 -y
Configure python2 as the default interpreter.
sudo alternatives --config python
Enter 2 for python2.
There are 2 programs which provide 'python'.
*+ 1 /usr/libexec/no-python
Enter to keep the current selection[+], or type selection number: 2
Download the SQL Server 2019 repository configuration file.
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo
Install SQL Server.
sudo dnf install mssql-server -y
Run myssql-conf setup to provide a password for the SA account and select the SQL Server edition.
sudo /opt/mssql/bin/mssql-conf setup
Choosing the SQL Server edition, I chose 2) Developer.
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.
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.
Enter the SQL Server system administrator password:
Memeriksa status mssql-server service.
sudo systemctl status mssql-server
In order to get a remote connection, open the SQL Server port in FirewallD.
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.
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo
sudo yum install -y mssql-tools unixODBC-devel -y
Add /opt/mssql-tools/bin/ into your PATH environment variable.
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.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.
sqlcmd -S localhost -U SA
Create a Database
Create a TestDB database.
CREATE DATABASE TestDB
The command above has not been executed, type GO to execute the previous command.
Displays all databases on the server.
SELECT Name from sys.Databases
Next create a table and enter two rows of data.
Switch to TestDB.
Create a table with the name Inventory.
CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT)
Insert data into tables.
INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154);
Finally type GO to execute the previous command.
Select and display data from the Inventory table.
SELECT * FROM Inventory WHERE quantity > 152
To exit sqlcmd type QUIT.
Good luck 🙂