Installing Microsoft Sql Server on Debian Linux


#1

Believe it or not, Microsoft Sql Server now officially supported under Linux by the Microsoft itself! Here is the link: https://www.microsoft.com/en-us/sql-server/sql-server-vnext-including-Linux

It is still on the beta stage and some of the advanced features not supported yet. But it is quite usable for general usage.

You can find installation instructions for Ubuntu Linux, but Debian not included. However, it is possible to install on Debian Jessie with using instructions for Ubuntu Linux:

Add Microsoft repositories into apt:

$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
$ curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | \
                sudo tee /etc/apt/sources.list.d/mssql-server.list

Update apt package database and install mssql-server package:

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

After package installation, you need to run /opt/mssql/bin/sqlservr-setup script:

$ sudo /opt/mssql/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.

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? If so, please type "YES": YES

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
/opt/mssql/bin/sqlservr-setup: line 106: [: !=: unary operator expected
Do you wish to enable SQL Server to start on boot? [y/n]:

Now you can check the default sql server port 1433 listening or not:

$ sudo lsof -i :1433
COMMAND    PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sqlservr 15020 mssql   65u  IPv4 152906      0t0  TCP *:ms-sql-s (LISTEN)

As you can see, port 1433 listened by sqlservr process.

If you want to connect sql server from Linux console, you can use sqsh, if you don’t have it, install first:

$ sudo apt-get install sqsh

To connect sql server as administrator account (sa):

$ sqsh -S localhost -U sa
Password: 
1> CREATE DATABASE test1
2> go
1> SELECT Name from sys.Databases
2> go

It is also possible to connect through Microsoft Sql Server Management Studio: