Install MSSQL Server in Linux Ultimate Step by Step Guide RHEL / Centos

Recent initiative by Microsoft to offer SQL Database product availability in Linux Operating system in part of that Microsoft released RPM packages for Linux. In this Article we are going to see how to Install MSSQL Server in Linux Ultimate Step by Step Guide RHEL / Centos.

Environment : Red Hat Enterprise Linux 7 & Centos 7.  We have used for this demonstration.

Minimum Hardware Requirements

  • Minimum 4GB RAM
  • Disk Space 4GB minimum
  • File System XFS Or Ext4 will be supported
  • Distros RHEL 7 / Centos 7 / MAC / Ubuntu 16.04 LTS or above versions
  • Enable 1433 port from Firewall for SQL communication to other clients
  • CPU i5 or above models

Install MSSQL Server in Linux Process

Configuring  YUM repo

Microsoft is already providing required packages through YUM repository, we have to download repo config and install mssql server in Linux.

[root@Arkit-Serv ~]# cd /etc/yum.repos.d/

[root@Arkit-Serv yum.repos.d]# wget https://packages.microsoft.com/config/rhel/7/mssql-server.repo [root@Arkit-Serv yum.repos.d]# ls mssql-server.repo  redhat.repo

Check repo status

[root@Arkit-Serv yum.repos.d]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                                                       repo name                                                                      status
packages-microsoft-com-mssql-server                                           packages-microsoft-com-mssql-server                                            2
repolist: 2

Installa packages using YUM

[root@Arkit-Serv ~]# yum install mssql-server
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package mssql-server.x86_64 0:14.0.1.246-6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================
 Package                           Arch                        Version                              Repository                                                Size
============================================================================================
Installing:
 mssql-server                      x86_64                      14.0.1.246-6                         packages-microsoft-com-mssql-server                      138 M

Transaction Summary
=============================================================================================
Install  1 Package

Total download size: 138 M
Installed size: 138 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/packages-microsoft-com-mssql-server/packages/mssql-server-14.0.1.246-6.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Public key for mssql-server-14.0.1.246-6.x86_64.rpm is not installed
mssql-server-14.0.1.246-6.x86_64.rpm                                                                                                        | 138 MB  00:03:30
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
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
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mssql-server-14.0.1.246-6.x86_64                                                                                                                1/1

+-------------------------------------------------------------------+
| Please run /opt/mssql/bin/sqlservr-setup to complete the setup of |
|                  Microsoft(R) SQL Server(R).                      |
+-------------------------------------------------------------------+

  Verifying  : mssql-server-14.0.1.246-6.x86_64                                                                                                                1/1

Installed:
  mssql-server.x86_64 0:14.0.1.246-6

Complete!

Run MSSQL Server Setup

As per the above command output MSSQL package installation completed, Now We have to setup sql server, to setup SQL Server we have to run below mentioned commands

[root@Arkit-Serv yum.repos.d]# cd /opt/mssql/bin/
[root@Arkit-Serv bin]# pwd
/opt/mssql/bin
[root@Arkit-Serv bin]# ./sqlservr-setup
Microsoft(R) SQL Server(R) Setup

You can abort setup at anytime by pressing Ctrl-C. Start this program
with the --help option for information about running it in unattended
mode.

Please enter a password for the system administrator (SA) account:
Please confirm the password for the system administrator (SA) account:

Setting system administrator (SA) account password...

Do you wish to start the SQL Server service now? [y/n]: y
Do you wish to enable SQL Server to start on boot? [y/n]: y
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server-telemetry.service to /usr/lib/systemd/system/mssql-server-telemetry.service.

Setup completed successfully.

Check MSSQL Service Status in Linux

MSSQL Service deployed Successfully, Now Verify MSSQL Service is running or not using systemctl status mssql-server

[root@Arkit-Serv bin]# systemctl status mssql-server
● mssql-server.service - Microsoft(R) SQL Server(R) Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2016-11-23 01:12:42 PST; 1min 48s ago
 Main PID: 2492 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ├─2492 /opt/mssql/bin/sqlservr
           └─2501 /opt/mssql/bin/sqlservr

Open Port 1433 from firewall to communicate with clients

[root@Arkit-Serv ~]# firewall-cmd --permanent --add-port=1433/tcp
success
[root@Arkit-Serv ~]# firewall-cmd --reload
success

Access MSSQL Instance from Windows Through SQL Management Studio

To Access MSSQL instance from windows machine, Install SQL Management Studio first, then open Run –> ssms

ssms command to open SQL Management Studio

Accessing MSSQL Server from Windows client

Accessing MSSQL Server from Windows client

Select Server type as Database Engine –> Provide SQL Server IP/ Name (Linux Machine IP) –> Login Name (sa by default) –> Provide Password. Install MSSQL Server in Linux

Default List of Databases

Check MSSQL version by running sample query

Linux MSSQL Version

That’s it MSSQL Server installation is completed successfully and accessible from Windows client through SQL Management Studio. Install MSSQL Server in Linux

Related Articles

SQL Installation in Windows Server

Check installation Status of SQL Server

 

Thanks for your wonderful Support and Encouragement