How to install Microsoft SQL Server 2019 on CentOS 7 / Fedora

(: March 26, 2019)

SQL Server runs on Linux starting with SQL Server 2017. This SQL Server is the same SQL Server database engine running on Microsoft Operating systems, with many similar features and services.

This guide will take you through the steps to install Microsoft SQL Server 2019 on CentOS 7 / Fedora 29/ Fedora 28. As of this writing, SQL Server 2019 9 is available in Preview mode, but I’ll update the article once it is available for general public.

Step 1: Install Microsoft SQL Server 2019 on CentOS 7 / Fedora 29/28

Microsoft SQL Server 2019 is available from Preview (2019) repository. Add the repository to your CentOS 7 / Fedora by running the following commands on your terminal.{text-align:left} img{margin:0 auto 0 0}
sudo curl -o /etc/yum.repos.d/mssql-server.repo

This will download  SQL Server 2019 repository to /etc/yum.repos.d/mssql-server.repo

Update your system cache:

sudo yum makecache # CentOS 7
sudo dnf makecache # Fedora

Then install SQL server 2019:

sudo yum install -y mssql-server

For Fedora, run:

sudo dnf install -y mssql-server

To get info about the installed package, run:

$ rpm -qi mssql-server
Name        : mssql-server
Version     : 15.0.1100.94
Release     : 1
Architecture: x86_64
Install Date: Sat 17 Nov 2018 09:12:15 AM UTC
Group       : Unspecified
Size        : 1289243002
License     : Commercial
Signature   : RSA/SHA256, Tue 06 Nov 2018 10:12:05 PM UTC, Key ID eb3e94adbe1229cf
Source RPM  : mssql-server-15.0.1100.94-1.src.rpm
Build Date  : Tue 06 Nov 2018 08:47:29 AM UTC
Build Host  : hls-cent3-prod-build-cent73-03
Relocations : (not relocatable)
Summary     : Microsoft SQL Server Relational Database Engine
Description :
The mssql-server package contains the Microsoft SQL Server Relational Database Engine.

Step 2: Initialize MS SQL Database Engine

After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition.

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

1. Select an edition you’d like to use

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)
  7) Enterprise Core (PAID)
  8) I bought a license through a retail sales channel and have a product key to enter.

For me. I’ll go with 2 – Developer (free, no production use rights).

2. Accept the license terms

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

3. Set SQL Server system administrator password

Enter the SQL Server system administrator password: <Password>
Confirm the SQL Server system administrator password:<Confirm Password>
Configuring SQL Server...

sqlservr: This program requires a machine with at least 2000 megabytes of memory.
/opt/mssql/bin/sqlservr: This program requires a machine with at least 2000 megabytes of memory.

Initial setup of Microsoft SQL Server failed. Please consult the ERRORLOG
in /var/opt/mssql/log for more information.

Step 3: Install SQL Server command-line tools

Then install mssql-tools with the unixODBC developer package.

sudo curl -o /etc/yum.repos.d/msprod.repo
sudo yum -y install mssql-tools unixODBC-devel

Step 4: Start and enable mssql-server  service

Start mssql-server  service

sudo systemctl start mssql-server

Enable it to start on system boot

sudo systemctl enable mssql-server

Add /opt/mssql/bin/ to your $PATH variable

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

Source the file to start using MS SQL executable binaries in your current shell session

source /etc/profile.d/

If you have an active Firewalld service, allow SQL Server ports for remote hosts to connect:

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

Step 4: Test SQL Server

Connect to the SQL Server and verify it is working.

$ sqlcmd -S localhost -U SA

Authenticate with the password set in Step 2.

Show Database users:

1> select name from sysusers;
2> go

Create a test database:

# Create new
SELECT Name from sys.Databases
USE mytestDB
CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT)
INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154);
SELECT * FROM Inventory LIMIT 1;

Show databases on the SQL Server.

1> select name,database_id from sys.databases;
2> go

Drop a database:

1> drop database testDB;
2> go

For SQL Server 2017:

How to install MS SQL on Ubuntu 18.04 LTS

How to install Microsoft SQL Server on RHEL / CentOS 8{text-align:left} img{margin:0 auto 0 0}

Related Posts