SQL Server for Linux on RHEL 8

Steps taken and followed from:

https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-red-hat?view=sql-server-ver16&tabs=rhel8

curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2022.repo

1. Download repository config file as root on host using curl

[root@dhome01 ~]# curl -o /etc/yum.repos.d/mssql-server.repo 

https://packages.microsoft.com/config/rhel/8/mssql-server-2022.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   232  100   232    0     0    209      0  0:00:01  0:00:01 --:--:--   209
yum install -y mssql-server

2. Install SQL Server

[root@dhome01 ~]# yum install -y mssql-server
Updating Subscription Management repositories.
packages-microsoft-com-mssql-server-2022                                                                                                               38 kB/s |  18 kB     00:00    
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)                                                                                               14 kB/s | 4.5 kB     00:00    
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)                                                                                              6.5 MB/s |  58 MB     00:08    
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)                                                                                                  12 kB/s | 4.1 kB     00:00    
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)                                                                                                 6.5 MB/s |  64 MB     00:09    
Last metadata expiration check: 0:00:01 ago on Wed 27 Dec 2023 17:54:29 GMT.
Dependencies resolved.
======================================================================================================================================================================================
 Package                               Architecture                    Version                                Repository                                                         Size
======================================================================================================================================================================================
Installing:
 mssql-server                          x86_64                          16.0.4095.4-1                          packages-microsoft-com-mssql-server-2022                          252 M
Installing dependencies:
 libatomic                             x86_64                          8.5.0-20.el8                           rhel-8-for-x86_64-baseos-rpms                                      25 k

Transaction Summary
======================================================================================================================================================================================
Install  2 Packages

Total download size: 252 M
Installed size: 1.2 G
Downloading Packages:
(1/2): libatomic-8.5.0-20.el8.x86_64.rpm                                                                                                               23 kB/s |  25 kB     00:01    
(2/2): mssql-server-16.0.4095.4-1.x86_64.rpm                                                                                                          8.2 MB/s | 252 MB     00:30    
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                 8.2 MB/s | 252 MB     00:30     
packages-microsoft-com-mssql-server-2022                                                                                                              4.2 kB/s | 983  B     00:00    
Importing GPG key 0xBE1229CF:
 Userid     : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
 Fingerprint: BC52 8686 B50D 79E3 39D3 721C EB3E 94AD BE12 29CF
 From       : https://packages.microsoft.com/keys/microsoft.asc
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                              1/1 
  Installing       : libatomic-8.5.0-20.el8.x86_64                                                                                                                                1/2 
  Running scriptlet: libatomic-8.5.0-20.el8.x86_64                                                                                                                                1/2 
  Running scriptlet: mssql-server-16.0.4095.4-1.x86_64                                                                                                                            2/2 
  Installing       : mssql-server-16.0.4095.4-1.x86_64                                                                                                                            2/2 
  Running scriptlet: mssql-server-16.0.4095.4-1.x86_64                                                                                                                            2/2 
Locale en_GB not supported. Using en_US.

+--------------------------------------------------------------+
Please run 'sudo /opt/mssql/bin/mssql-conf setup'
to complete the setup of Microsoft SQL Server
+--------------------------------------------------------------+


  Verifying        : mssql-server-16.0.4095.4-1.x86_64                                                                                                                            1/2 
  Verifying        : libatomic-8.5.0-20.el8.x86_64                                                                                                                                2/2 
Installed products updated.

Installed:
  libatomic-8.5.0-20.el8.x86_64                                                           mssql-server-16.0.4095.4-1.x86_64                                                          

Complete!

/opt/mssql/bin/mssql-conf setup

3. Run SQL Server setup

[root@dhome01 ~]# /opt/mssql/bin/mssql-conf setup
Locale en_GB not supported. Using en_US.
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.
  9) Standard (Billed through Azure) - Use pay-as-you-go billing through Azure.
 10) Enterprise Core (Billed through Azure) - Use pay-as-you-go billing through Azure.

Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=2109348

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.
By choosing an edition billed Pay-As-You-Go through Azure, you are verifying 
that the server and SQL Server will be connected to Azure by installing the 
management agent and Azure extension for SQL Server.

Enter your edition(1-10): 2
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from: https://aka.ms/useterms

The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010

Do you accept the license terms? [Yes/No]:Yes


Choose the language for SQL Server:
(1) English
(2) Deutsch
(3) Español
(4) Français
(5) Italiano
(6) 日本語
(7) 한국어
(8) Português
(9) Руѝѝкий
(10) 中文 – 简体
(11) 中文 (繝体)
Enter Option 1-11: 1
Enter the SQL Server system administrator password: 
Confirm the SQL Server system administrator password: 
Configuring SQL Server...

ForceFlush is enabled for this instance. 
ForceFlush feature is enabled for log durability.
Created symlink /etc/systemd/system/multi-user.target.wants/mssql-server.service → /usr/lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.
systemctl status mssql-server

4. Verify SQL Server service is running

[root@dhome01 ~]# systemctl status mssql-server
● mssql-server.service - Microsoft SQL Server Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-12-27 17:59:31 GMT; 6min ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 49858 (sqlservr)
    Tasks: 220
   Memory: 896.7M
   CGroup: /system.slice/mssql-server.service
           ├─49858 /opt/mssql/bin/sqlservr
           └─49895 /opt/mssql/bin/sqlservr

Dec 27 17:59:44 dhome01.localdomain sqlservr[49895]: [158B blob data]
Dec 27 17:59:44 dhome01.localdomain sqlservr[49895]: [155B blob data]
Dec 27 17:59:44 dhome01.localdomain sqlservr[49895]: [193B blob data]
Dec 27 17:59:44 dhome01.localdomain sqlservr[49895]: [66B blob data]
Dec 27 17:59:45 dhome01.localdomain sqlservr[49895]: [75B blob data]
Dec 27 17:59:45 dhome01.localdomain sqlservr[49895]: [96B blob data]
Dec 27 17:59:45 dhome01.localdomain sqlservr[49895]: [100B blob data]
Dec 27 17:59:45 dhome01.localdomain sqlservr[49895]: [71B blob data]
Dec 27 17:59:45 dhome01.localdomain sqlservr[49895]: [124B blob data]
Dec 27 18:04:45 dhome01.localdomain sqlservr[49895]: [75B blob data]
sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
sudo firewall-cmd --reload

5. Allow remote connections by opening the firewall

curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo
yum remove mssql-tools unixODBC-utf16 unixODBC-utf16-devel
yum install -y mssql-tools18 unixODBC-devel
yum check-update
yum update mssql-tools18

6. Install the SQL Server command-line tools

[root@dhome01 ~]# curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 192 100 192 0 0 960 0 –:–:– –:–:– –:–:– 960
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/rhel/8/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc[root@dhome01 ~]# yum remove mssql-tools unixODBC-utf16 unixODBC-utf16-devel
Updating Subscription Management repositories.
No match for argument: mssql-tools
No match for argument: unixODBC-utf16
No match for argument: unixODBC-utf16-devel
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
[root@dhome01 ~]# yum install -y mssql-tools18 unixODBC-devel
Updating Subscription Management repositories.
packages-microsoft-com-prod 6.3 MB/s | 9.4 MB 00:01
Last metadata expiration check: 0:00:15 ago on Wed 27 Dec 2023 23:11:03 GMT.

Dependencies resolved.

Package Architecture Version Repository Size

Installing:
mssql-tools18 x86_64 18.2.1.1-1 packages-microsoft-com-prod 292 k
unixODBC-devel x86_64 2.3.11-1.rh packages-microsoft-com-prod 53 k
Upgrading:
unixODBC x86_64 2.3.11-1.rh packages-microsoft-com-prod 274 k
Installing dependencies:
msodbcsql18 x86_64 18.3.2.1-1 packages-microsoft-com-prod 925 k

Transaction Summary
Install 3 Packages
Upgrade 1 Package

Downloading Packages:
(1/4): unixODBC-devel-2.3.11-1.rh.x86_64.rpm 36 kB/s | 53 kB 00:01
(2/4): unixODBC-2.3.11-1.rh.x86_64.rpm 2.7 MB/s | 274 kB 00:00
(3/4): mssql-tools18-18.2.1.1-1.x86_64.rpm 159 kB/s | 292 kB 00:01
(4/4): msodbcsql18-18.3.2.1-1.x86_64.rpm 431 kB/s | 925 kB 00:02

Total 715 kB/s | 1.5 MB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : unixODBC-2.3.11-1.rh.x86_64 1/5
Running scriptlet: unixODBC-2.3.11-1.rh.x86_64 1/5
Running scriptlet: msodbcsql18-18.3.2.1-1.x86_64 2/5
The license terms for this product can be downloaded from
https://aka.ms/odbc18eula and found in
/usr/share/doc/msodbcsql18/LICENSE.txt . By entering ‘YES’,
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES
Please enter YES or NO
Do you accept the license terms? (Enter YES or NO)
YES
Installing : msodbcsql18-18.3.2.1-1.x86_64 2/5
Running scriptlet: msodbcsql18-18.3.2.1-1.x86_64 2/5
odbcinst: Driver installed. Usage count increased to 1.
Target directory is /etc

Running scriptlet: mssql-tools18-18.2.1.1-1.x86_64 3/5
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools18/LICENSE.txt . By entering ‘YES’,
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES
Installing : mssql-tools18-18.2.1.1-1.x86_64 3/5
Installing : unixODBC-devel-2.3.11-1.rh.x86_64 4/5
Cleanup : unixODBC-2.3.7-1.el8.x86_64 5/5
Running scriptlet: unixODBC-2.3.7-1.el8.x86_64 5/5
Running scriptlet: msodbcsql18-18.3.2.1-1.x86_64 5/5
Running scriptlet: unixODBC-2.3.7-1.el8.x86_64 5/5
Verifying : msodbcsql18-18.3.2.1-1.x86_64 1/5
Verifying : mssql-tools18-18.2.1.1-1.x86_64 2/5
Verifying : unixODBC-devel-2.3.11-1.rh.x86_64 3/5
Verifying : unixODBC-2.3.11-1.rh.x86_64 4/5
Verifying : unixODBC-2.3.7-1.el8.x86_64 5/5
Installed products updated.

Upgraded:
unixODBC-2.3.11-1.rh.x86_64
Installed:
msodbcsql18-18.3.2.1-1.x86_64 mssql-tools18-18.2.1.1-1.x86_64 unixODBC-devel-2.3.11-1.rh.x86_64

Complete!

7. Test a Local connect to MS SQLServer

su - mssql

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

sqlcmd -S localhost -U sa -C

You will need to enter sa password used during setup

The ‘C’ option, means Trust Server Certificate