Install Microsoft SQL Server (MS SQL) on RHEL (CentOS) / Ubuntu – Evaluation version

Install Microsoft SQL Server on Linux
Install Microsoft SQL Server on Linux

Microsoft has released SQL Server for Redhat Enterprise Linux and Ubuntu; you can now start testing this latest preview of SQL Server in your environment.

This version is still in preview; it is meant for testing and development purpose only. Try it at your own risk.

System Requirements:

Make sure your system meets below hardware requirements.

Memory Atleast 3.25 GB
File System XFS or EXT4
Disk space Minimum 1 GB
Processor type x64-compatible only

Supported Operating Systems:

  • Redhat Enterprise Linux 7.3/7.2
  • Ubuntu 16.04

Setup Repository:

### Ubuntu 16.04 ###

$ sudo apt-get install -y wget curl
$ wget https://packages.microsoft.com/keys/microsoft.asc
$ sudo apt-key add microsoft.asc
$ curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql.list
$ curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

### CentOS 7 ###

# yum -y install wget
# wget https://packages.microsoft.com/config/rhel/7/mssql-server.repo
# wget https://packages.microsoft.com/config/rhel/7/prod.repo
# mv *.repo /etc/yum.repos.d/

Install MS SQL Server on Linux:

### Ubuntu 16.04 ###

$ sudo apt-get update
$ sudo apt-get install -y mssql-server

### CentOS 7 ###

# yum install -y mssql-server

Setup MS SQL server.

### Ubuntu 16.04 ###

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

### CentOS 7 ###

# /opt/mssql/bin/mssql-conf setup

Output:

The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388
and found in /usr/share/doc/mssql-server/LICENSE.TXT.

Do you accept the license terms? [Yes/No]:Yes
Enter the SQL Server system administrator password: Enter Admin Password
Confirm the SQL Server system administrator password: Re Enter Admin Password
Configuring SQL Server...

This is an evaluation version.  There are [119] days left in the evaluation period.
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.

Start the MS SQL Service (Optional).

### Ubuntu 16.04 ###

$ sudo systemctl start mssql-server
$ sudo systemctl enable mssql-server

### CentOS 7 ###

# systemctl start mssql-server
# systemctl enable mssql-server

Install SQL Server tools on Linux:

It provides command line tools (sqlcmd and bcp), ODBC drivers and their dependencies.

### Ubuntu 16.04 ###

$ sudo apt-get install -y mssql-tools

### CentOS 7 ###

# yum install -y mssql-tools

Steps:

Accept License terms

Firewall:

Configure the firewall to allow 1433 port so that we can access the SQL server from external machines.

FirewallD:

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

UFW:

$ sudo ufw allow 8080/tcp
$ sudo ufw reload

Connect to MS SQL server:

sqlcmd command now be found /opt/mssql-tools/bin directory. To make tools command available to shell path, run the following command.

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

Once the installation is complete, connect to MS SQL server using the following command.

sqlcmd -H 127.0.0.1 -U sa

Password: 
1>

That’s All.

Reference:

Official Documentation

Further Reading

You might also like