SQL Server on Linux
Creating a Linux virtual machineSQL Server for Linux is available on three different platforms: Red Hat, Ubuntu and the Docker image (which can run on MacOs for example). In order to try out the installation, I chose to set up an Ubuntu server in Azure. To do this, you need to go to https://portal.azure.com and select Virtual Machines on the left-hand menu, followed by the add button to create a new virtual machine. From the available servers, you can choose Ubuntu Server, then Ubuntu Server 16.04 LTS. This leads to the terms and conditions page on which you click the Create button to begin the creation process. At this point you will be presented with the following form to fill in.At this point, the main decision you have to make is whether you want to use a password or an SSH public key to connect to the Ubuntu Server. If you choose a public key (the more secure option) you will need to install PuTTY, which you can get from the WinSCP download page. To find the installer scroll down the page and click on the PuTTY installation package. This will install PuTTY, Puttygen and Pageant. It is also worth installing WinSCP itself as we will use it later to connect to the Linux server and upload a backup file. To create the public/private key pair, you will need to run puttygen.exe and generate a new key.The public key can be copied and pasted into the form, but make sure you save the private key for later. Clicking OK takes you to the next screen where you can choose the size of your virtual machine.Obviously the size you choose will depend on what you want to use the server for. You don’t have to select one of the recommended sizes, and can instead choose from the large selection of sizes available.The next screen is for configuring optional settings, and can be skipped through by pressing OK again. You will then be presented with a summary page, where you review your settings before pressing OK to create the virtual machine. The deployment process will take a few minutes to complete, at which point you will be presented with a screen showing the essential machine information. In order to connect to the new virtual machine you will need to make a note of the IP address. Before you can connect however, we need to set up the private SSH key we saved earlier. To do this you need to run pageant.exe, which will be found along with the other PuTTY programs you installed. On opening Pageant, you will see a window where you can click to add a new key. Select the private key (ppk) file and click Open. As long as Pageant is running in the background, it will enable you to connect to anything that uses this key.
Installing SQL ServerThe next step is to run PuTTY itself.Enter the IP address of your new server and click Open. PuTTY is configured by default to use Pageant where possible to match private and public SSH keys, so there shouldn’t be anything else you need to do here. If you do have problems, it’s worth checking under Connection > SSH > Auth where you should see a checkbox called “Attempt authentication using Pageant”. This needs to be checked for PuTTY to use the keys stored in Pageant.Click Open to connect to your new server. Enter the login name you chose when configuring the machine and PuTTY should check Pageant for the matching private key and log you in.Now you can begin the installation of SQL Server. This is a remarkably simple procedure, involving only a few commands.First you import the GPG (GNU Privacy Guard) keys:
Then you register the Microsoft SQL Server Ubuntu repository:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
These commands then install SQL Server:
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
After SQL Server installs (which should only take a couple of minutes), run this command to complete the configuration:
sudo apt-get update
sudo apt-get install -y mssql-server
You will be asked to accept the licence terms and prompted for an SA password. You can also choose to start the SQL Server service and whether it should start on boot.