handbook, books, note, tutorial, troubleshooting

Install SQL Server on Ubuntu 16.04 with SQL Server tools

Install SQL Server on Ubuntu 16.04

You need at least 3.25GB of memory to run SQL Server on Linux. SQL Server Engine has only been tested up to 256GB of memory at this time.

Install SQL Server

To install the mssql-server Package on Ubuntu, follow these steps:
  1. Import the public repository GPG keys:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

2. Register the Microsoft SQL Server Ubuntu repository:

curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list

3. Run the following commands to install SQL Server:

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

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-43 linux-headers-4.4.0-43-generic
  linux-image-4.4.0-43-generic linux-image-extra-4.4.0-43-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
Suggested packages:
The following NEW packages will be installed:
  libc++1 mssql-server
0 upgraded, 2 newly installed, 0 to remove and 16 not upgraded.
Need to get 144 MB of archives.
After this operation, 682 MB of additional disk space will be used.
Get:1 https://packages.microsoft.com/ubuntu/16.04/mssql-server xenial/main amd64 mssql-server amd64 [144 MB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 libc++1 amd64 3.7.0-1 [226 kB]
Fetched 144 MB in 9min 22s (256 kB/s)                                          
Preconfiguring packages ...
Selecting previously unselected package libc++1:amd64.
(Reading database ... 309306 files and directories currently installed.)
Preparing to unpack .../libc++1_3.7.0-1_amd64.deb ...
Unpacking libc++1:amd64 (3.7.0-1) ...
Selecting previously unselected package mssql-server.
Preparing to unpack .../mssql-server_14.0.1.246-6_amd64.deb ...
Unpacking mssql-server ( ...
Processing triggers for libc-bin (2.23-0ubuntu4) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libc++1:amd64 (3.7.0-1) ...
Setting up mssql-server ( ...

| Please run /opt/mssql/bin/sqlservr-setup to complete the setup of |
|                  Microsoft(R) SQL Server(R).                      |

Processing triggers for libc-bin (2.23-0ubuntu4) ...
ds@ds:~$ sudo /opt/mssql/bin/sqlservr-setup
[sudo] password for ds: 
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

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
Do you wish to enable SQL Server to start on boot? [y/n]: n

You can use sqlservr-setup --enable-service to enable SQL Server to start
at boot.

Setup completed successfully.

4. After the package installation finishes, run the configuration script and follow the prompts. Make sure to specify a strong password for the SA account (Minimum length 8 characters, including uppercase and lowercase letters, base 10 digits and/or non-alphanumeric symbols).

sudo /opt/mssql/bin/sqlservr-setup

5. Once the configuration is done, verify that the service is running:
systemctl status mssql-server

SQL Server tools

1. Import the public repository GPG keys: 

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

2. Register the Microsoft Ubuntu repository:

curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

3. Update the sources list and run the installation command:

sudo apt-get update 
sudo apt-get install mssql-tools

Install SQL Server on Ubuntu 16.04 with SQL Server tools