Hamsa K
Editor
6 min read | 4 years ago

How to Install MS SQL Server on Centos 7

Install MS SQL Server 2019 on centos 7

Microsoft SQL Server is a relational database management system developed by Microsoft.Microsoft haved added support for Linux platform in MS SQL Server 2017.Here we will install and perform basic setup of MSSQL in the RHEL based Linux distribution CentOS.

Make sure your system RAM should be 2 to 3 GB and login with root user or any other user with sudo privileges.Here i have loggedin with root user.

Step 1: Install Mssql server

First we need to download and add mssql server 2019 repo

[root@localhost ~]# curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo

Install mssql server 2019 using yum.

Also Read -> How to Install Docker on Centos 7

[root@localhost ~]# yum install -y mssql-server

Once the installation has completed, you have to run /opt/mssql/bin/sqlservr-setup bash script to complete the setup process as shown below.

[root@localhost ~]# /opt/mssql/bin/mssql-conf setup

Select an edition you would 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) - 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.

Here i have selected Evaluation edition,Accept the license terms and set SQL server system administrator password.

Enter your edition(1-8): 1
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=2104078&clcid=0x409
The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409
Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server...

Once the configuration is done, verify that the service is running with the following command.

[root@localhost ~]# systemctl status mssql-server.service

output:

[root@localhost ~]# systemctl status mssql-server.service
● 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 2020-10-21 08:02:47 BST; 1min 26s ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 10426 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ├─10426 /opt/mssql/bin/sqlservr
           └─10446 /opt/mssql/bin/sqlservr

Step 2: Install command line tools

Download and install Microsoft yum repository to install SQL Server tools.

wget https://packages.microsoft.com/config/rhel/7/prod.repo -O /etc/yum.repos.d/msprod.repo

Now install mssql-tools using yum command.

Also Read -> How to Install Webmin on Centos 7

[root@localhost ~]# yum install mssql-tools unixODBC-devel

SQL Server tools has been installed in /opt/mssql/bin directory. Add this directory to your $PATH environment variable as shown below.

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

We hope you are following "How to Install MS SQL Server on Centos 7" step by step carefully. The remaining steps will help you to finish the upgrade process..

Step 3: setup firewall

If firewall is running on your system then configure firewall to allow 1433 port so we can access the SQL server from Remote systems.

firewall-cmd --zone=public --add-port=1433/tcp --permanent
firewall-cmd --reload

Step 4: Test connection

To connect database server, run following command

sqlcmd -S localhost -U SA

output:

[root@localhost ~]# sqlcmd -S localhost -U SA
Password:
1>

create test database 

1> CREATE DATABASE lampblogs;
2> GO
1> use lampblogs;
2> GO
Changed database context to 'lampblogs'.

check with following query to return the name of all of the databases.

1> SELECT Name from sys.Databases;
2> GO
Name
--------------------------------------------------------------------------------------------------------------------------------
master
tempdb
model
msdb
lampblogs
(5 rows affected)

Now you have successfully configured MS SQL Server 2019 on CentOS 7 server.

Also Read -> How to Install Nodejs on Centos 7



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy