Install SQL Server 2017 on Linux

This post is to guide SQL Server 2017 installation on Linux.

Once the Linux VM is build follow the instructions below to install SQL Server latest release.

Step 1: Download the Microsoft SQL Server Red Hat repository configuration file:

  • Issue following command as root user:-
curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo

Step 2: Install SQL Server:

yum -y install mssql-server

Step 3: Setup SQL Server Installation:

/opt/mssql/bin/mssql-conf setup
  • The Setup would prompt for the type of edition and sa password, please supply the same on the command prompt itself. For reference please find the complete output of the setup below:-
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=852741&clcid=0x409

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

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

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

Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409

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-7): 2
Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server...

This is an evaluation version.  There are [132] days left in the evaluation period.
Setup has completed successfully. SQL Server is now starting.

This completes the SQL Server installation on Linux, you can cross check the SQL Server service and processes from below commands:-

  • Service:
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 2017-09-13 13:40:54 BST; 6min ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 6017 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ├─6017 /opt/mssql/bin/sqlservr
           └─6048 /opt/mssql/bin/sqlservr

Sep 13 13:41:08 dbalab1 sqlservr[6017]: 2017-09-13 13:41:08.95 spid6s      8 transactions rolled forward in database 'msdb' (4:0). This is an informat... required.
Sep 13 13:41:09 dbalab1 sqlservr[6017]: 2017-09-13 13:41:09.06 spid9s      Polybase feature disabled.
Sep 13 13:41:09 dbalab1 sqlservr[6017]: 2017-09-13 13:41:09.06 spid9s      Clearing tempdb database.
Sep 13 13:41:09 dbalab1 sqlservr[6017]: 2017-09-13 13:41:09.10 spid6s      0 transactions rolled back in database 'msdb' (4:0). This is an information... required.
Sep 13 13:41:09 dbalab1 sqlservr[6017]: 2017-09-13 13:41:09.73 spid9s      Starting up database 'tempdb'.
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.19 spid9s      The tempdb database has 1 data file(s).
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.20 spid22s     The Service Broker endpoint is in disabled or stopped state.
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.21 spid22s     The Database Mirroring endpoint is in disabled or stopped state.
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.32 spid22s     Service Broker manager has started.
Sep 13 13:41:10 dbalab1 sqlservr[6017]: 2017-09-13 13:41:10.46 spid6s      Recovery is complete. This is an informational message only. No user action is required.
  • Processes:
ps -ef | grep sqlservr | grep -v grep

mssql     6017     1  0 13:40 ?        00:00:01 /opt/mssql/bin/sqlservr
mssql     6048  6017  8 13:40 ?        00:00:31 /opt/mssql/bin/sqlservr
  • Port:
netstat -tulpn | grep 1433

tcp        0      0 0.0.0.0:1433            0.0.0.0:*               LISTEN      6048/sqlservr
tcp6       0      0 :::1433                 :::*                    LISTEN      6048/sqlservr

Step 4: Connect to the SQL Server Instance:

For connecting you need to first install mssql-tools (sqlcmd & bcp), which can be installed by executing below command:-

Download:

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

Install:

yum install -y mssql-tools unixODBC-devel

Mssq-tools has been installed now but to use them add the mssql-tools binaries to your path:

export PATH="$PATH:/opt/mssql-tools/bin"

To permanently add it, enter below command for every user by which you want to access mssql-tools binaries:-

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

Once this is done you can connect to SQL Server Instance by executing below command:-

sqlcmd -S localhost -U SA -P ''

Step 5: Now to allow remote connection (To connect via your favorite SSMS) you need to disable firewall, this can be achieved by:

Disabling firewall:

systemctl disable firewalld

OR Allow port 1433:

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

Step 6: Install SQL Server Agent

yum install mssql-server-agent
systemctl restart mssql-server

In the next article we would explore the directory structure of SQL Server on Linux, stay tuned. In case of any issues during installation please comment below and we’ll try to work together to resolve the issues.

2 thoughts on “Install SQL Server 2017 on Linux

  1. Pingback: SQL Server on Linux – Directory Structure | Oracle Database Internal Mechanism

  2. Pingback: SQL Server | Oracle Database Internal Mechanism

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.