SQL Server 2017 and Linux : Part 1

Today I will be writing about the new SQL 2017. It has been launched yesterday (Get your copy here) and one of the new and exciting features is you can now run it on a supported linux distribution (redhat, ubuntu, Suse, …)

As I have been working exclusively with Windows OS’es for the past 6 years, I did not touch Linux for quite a long time. So I’m excited about running my favorite database engine in a new OS. Is it asking for trouble to run it on Linux? Or isn’t it? Let’s find out!

First I did spin up an linux VM in Azure. The process is fairly straight forward (as is deploying any VM in Azure :-))

One thing worth checking is the connection method when creating the virtual machine. You can pick a password or create a public/private keypair and use that to connect. The password option is fairly simple, but ssh key thing does require some extra configuration. To do this you can use a tool like PuttyGen to generate the SSHKey.

Just fire up the PuttyGen tool, click Generate and move the mouse over the blank area like your life depends on it.

After shaking your mouse like a madmen, you get a public and private keypair.

For future deployments I suggest clicking the Save Button and storing them somewhere safe. Copy paste the public value into the Wizard and finish creating your VM. After some time*,  you get the notification your machine is ready, go and take out your favorite ssh tool. Connect using the private key file you saved earlier. If all went well, you should be able to connect to the Linux machine.

*you could get a coffee while the machine is deploying

As simple as it might seem, you can install SQL Server using the built-in package manager. For Ubuntu this is the apt-get command. Before running the SQL installation command, you first need to tell ubuntu to include packages from the Microsoft repositories. This can be done using the following commands:

This adds the repository key to the server and adds the repository URL to the package list. Update the packagelist after adding the key and go install SQL Server.

It will get the required dependancies from the repository and install the mssql server.

After some minutes, the installation completes. It tells you to run the configuration script using “sudo /opt/mssql/bin/mssql-conf setup”. Because the terminal asks me nicely to do so, I type in the command and hit enter.

After anwsering some questions about licensing and accepting the EULA you get the message SQL Server is starting up (hurray!). All this took less than 10 minutes to get up and running. This installation process is quite a lot faster than the Windows equivalent. You do get a lot less options, however for just setting up a SQL on a dev box using all defaults, this is really lightning fast. Eat that Windows!

Before connecting to it using the SQL Management Studio (17.0 or up) you will need to allow access to port 1433 on the server. You need to create an inbound rule on your network security group to do so. Access the NSG by clicking on the VM -> Networking -> Add inbound Port Rule.

After adding the firewall rule fire up the management studio and connect to the deployed VM. After connecting you can check the servername and version by running following commands or by using the SQL Management Studio

You really are running SQL on Linux at this time.
When reviewing the database instance you might notice the agent service missing. In SQL Server (on Windows) this is a seperate service, on linux this is part of the SQL Server process and needs to be installed as an sort of extension to SQL Server. Install the agent using the commandline :

Restart SQL Server and refresh the management server :

Voila, all done. This was not as hard as I thought it would be and it did deploy faster than the SQL 2017 did on my own portable. However when doing this in production, some additional configuration is required. You will need to set certain options (changing the collation, changing the default data paths for example) using the command line. You can’t seem to be able to do it from the SSMS.
Use the sudo /opt/mssql/bin/mssql-conf script to set these different options. A useful link might be the Microsoft documentation about this command : https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-mssql-conf.

This concludes the first part about running SQL Server on Linux.
Happy DBA’ing!

Share this post on

Author: Brecht Vuylsteke

Brecht Vuylsteke
Microsoft Infrastructure Consultant with a focus on SQL and SharePoint.

1 thought on “SQL Server 2017 and Linux : Part 1”

Leave a Comment

All fields are required. Your email address will not be published.