This post is to guide SQL Server 2017 installation on Linux.
- You can create a Linux VM following my previous post of Installing Linux 7 on Oracle VirtualBox.
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.repo
Step 2: Install SQL Server:
yum -y install mssql-server
Step 3: Setup SQL Server Installation:
- 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  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:-
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: 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: 2017-09-13 13:41:09.06 spid9s Polybase feature disabled. Sep 13 13:41:09 dbalab1 sqlservr: 2017-09-13 13:41:09.06 spid9s Clearing tempdb database. Sep 13 13:41:09 dbalab1 sqlservr: 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: 2017-09-13 13:41:09.73 spid9s Starting up database 'tempdb'. Sep 13 13:41:10 dbalab1 sqlservr: 2017-09-13 13:41:10.19 spid9s The tempdb database has 1 data file(s). Sep 13 13:41:10 dbalab1 sqlservr: 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: 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: 2017-09-13 13:41:10.32 spid22s Service Broker manager has started. Sep 13 13:41:10 dbalab1 sqlservr: 2017-09-13 13:41:10.46 spid6s Recovery is complete. This is an informational message only. No user action is required.
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
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:-
curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
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:
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 '<YourPassword>'
Step 5: Now to allow remote connection (To connect via your favorite SSMS) you need to disable firewall, this can be achieved by:
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.