# Installing Microsoft Sql Server on Debian Linux

**URL:** <https://linux-tips.com/t/installing-microsoft-sql-server-on-debian-linux/476>\
**Category:** Database\
**Created:** [February 11, 2017, 8:02pm UTC](https://linux-tips.com/t/installing-microsoft-sql-server-on-debian-linux/476 "2017-02-11T20:02:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg](https://linux-tips.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@Greg](https://linux-tips.com/u/Greg)\
**Post date:** [February 11, 2017, 8:02pm UTC](https://linux-tips.com/t/installing-microsoft-sql-server-on-debian-linux/476/1 "2017-02-11T20:02:25Z")

</div>

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](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** :

```auto
$ 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:

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

```

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

```auto
$ 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:

```auto
$ 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:

```auto
$ sudo apt-get install sqsh

```

To connect sql server as administrator account (sa):

```auto
$ 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:

 ![](https://linux-tips.com/uploads/default/original/1X/ab18cda89f5a519d6a11cb354f08fea7194835d7.png)

---

<div class="post-metadata">

**Author:** ![AlejandroB](https://linux-tips.com/user_avatar/linux-tips.com/alejandrob/32/217_2.png) [@AlejandroB](https://linux-tips.com/u/AlejandroB)\
**Post date:** [January 23, 2021, 4:28pm UTC](https://linux-tips.com/t/installing-microsoft-sql-server-on-debian-linux/476/2 "2021-01-23T16:28:02Z")

</div>

**2021 UPDATE** Linux Debian 10 (Buster) needs to add these prerrequisites:  
$ `sudo apt install -y curl gnupg2`

AND use this source list instead of the Ubuntu 16.04

$ `curl https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list | \sudo tee /etc/apt/sources.list.d/mssql-server.list`
