This post was created to try and be a 'catch all' canonical question/answer pair for 'How do I Install MSSQL Server' and 'How Do I Install MSSQL Server Tools' questions.
I am looking to set up MS SQL Server for Linux, and quite possibly its tools (on the server itself or other systems) so I can interact with SQL Server. How can I go about doing this?
There are a couple different components here in packages from Microsoft repositories only.
mssql-server
- Microsoft SQL Server for Linux Previewmssql-tools
-sqlcmd
, etc. commands to interact with MSSQL Server.There are some evil caveats here:
mssql-server
and possibly not the tools either unless you are on 64-bit systems.mssql-server
installation steps (source)These steps cover setting up MS SQL Server for Linux Public Preview. This and the Docker method are the two methods for getting MSSQL Server for Linux set up.
To install the
mssql-server
Package on Ubuntu, follow these steps:Enter superuser mode.
Import the public repository GPG keys:
Register the Microsoft SQL Server Ubuntu repository:
Exit superuser mode.
Run the following commands to install SQL Server:
After the package installation finishes, run the configuration script and follow the prompts.
Once the configuration is done, verify that the service is running:
See: Quickstart: Install SQL Server and create a database on Ubuntu.
mssql-tools
Installation Steps (source)This section covers setting up of
mssql-tools
which includes thesqlcmd
command. These steps are needed for any systems in which you wish to use thesqlcmd
command or other Microsoft-originating utilities on Linux to interact with an MSSQL Server.(This is not required for other Python libraries for interacting with MSSQL, or other utilities such as DataGrip which can interact with servers, etc., which do not need the
mssql-tools
pacakge to operate.)Enter Superuser Mode
Import the public repository GPG keys:
Register the Microsoft Ubuntu repository:
Exit superuser mode:
Update the sources list and run the installation command:
Using Docker (amd64 only)
It is also possible to run MSSQL Server on Ubuntu using Docker. This can be done by following the steps below carefully:
If you are using Ubuntu 14.04 or any other release older than Xenial (16.04), you will need to install a newer version of Docker than the archives provide.
If so, follow the instructions on this page.
If not, simply run:
Verify that you can connect to the local Docker daemon using:
If you receive an error such as
Cannot connect to the Docker daemon.
, you will need to add yourself to thedocker
group:...where
<USERNAME>
is replaced with your username. You will need to log out and back in for the changes to take effect.Pull the MSSQL image from Docker Hub:
Create a directory on the host that will store data from the container and keep the value in an environment variable for convenience:
Start the container:
Replace
<PASSWORD>
with a unique value that will be used for authentication later.Verify that the container started without error:
If the
STATUS
column shows "Up ..." under theSTATUS
column, then everything is running correctly. If, however, an error is displayed:...then you can use
docker logs mssql
to obtain further information.To connect to the container from an application, simply specify port 1433.
By default, the container is started when you first
run
it. You can stop the container with:To remove the container, first stop it, and then run: