Install SQL Server 2017 in Ubuntu 17.04

Install SQL Server 2017 in Ubuntu 17.04

In this article, we are going to download and install SQL Server 2017 in Ubuntu 17.04. The prerequisite for this video is.

  • Ubuntu machine: Check this video for How to create a VM in Oracle Virtual Box for Ubuntu 17.04
    • Ubuntu System requirement. Ubuntu OS 16.04 or higher. Ram at least 3.25 GB.
  • A working internet connection

So let’s start.

I am assuming you are logged in your Ubuntu machine. Now follow steps for to download and install SQL Server 2017 in Ubuntu.

Install SQL Server 2017 in Ubuntu 17.04

  1. Open terminal. Press Ctrl + Alt + T to open the terminal in Ubuntu.
  2. Import the public repository GPG keys. Execute following command in Ubuntu terminal.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
  1. Register the Microsoft SQL Server Ubuntu repository: Run below command in terminal
sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list)"
  1. Run the following commands in terminal to install SQL Server: 
sudo apt-get update
sudo apt-get install -y mssql-server

Our SQL Server 2017 installation is completed. Now, we need to configure SQL Server

Configure SQL Server 2017 in Ubuntu 17.04

  1. Start SQL Server 2017 configuration using the following command. Execute it in terminal
sudo /opt/mssql/bin/mssql-conf setup
  • When you run above command we need to first accept the license term. Type Yes in Terminal and press enter
  • Then we need to select the SQL Server 2017 edition. At the time of writing this article SQL Server 2017 for Ubuntu is available in following editions
  1. Evaluation (free, no production use rights, 180-day limit)
  2. Developer (free, no production use rights)
  3. Express (free)
  4. Web (PAID)
  5. Standard (PAID)
  6. Enterprise (PAID)
  7. I bought a license through a retail sites channel and have a product key to enter

Based on your requirement type the appropriate number. For this article, we are going to select 2 and then Enter. (We need to type 2 and then enter in terminal)

  • Then we need to select the Installation language at the time of writing this article we have 11 options but I am going to select first Engish option. 1 is for English. You may select your preferred language.
  • Now finally we need to enterte the administrator password. This is for “sa” account. Type your password in the terminal and then hit enter. Confirm your password then again hit enter.

Note: If you are new to Ubuntu terminal then, just for your inormation, when you are going to type a password in terminal it is not visible to you. It means when you are typing the password in terminal the characters which used in your password is there but it is not visible in the terminal.

Note: If you are using a release candidate for SQL Server then you may see below message.

 This is an evaluation version. There are [180] days left in the evaluation period.

Finally, our SQL Server 2017 Installation is completed successfully in Ubuntu 17.04. What next? Now we are going to install SQL Server 2017 command line tool for executing TSQL Queries

Install SQL Server 2017 Command Line tools.Below steps are going to download and install SQL Server Command Line tools: sqlcmd and bcp

  1. Import the public repository GPG keys: Execute below command in terminal
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
  1. Register the Microsoft Ubuntu repository: Execute below command in terminal
sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list)"
  1. Update the sources list and run the installation command with the unixODBC developer package:
sudo apt-get update
sudo apt-get install -y mssql-tools unixodbc-dev

Above command is now going to install SQL Server 2017 command line tools in /opt/mssql-tools/bin/ path. Now we are going to set PATH environment variable so we can directly run SQLCMD in terminal for this we need to run following command

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

Now jsut for testing we are going to type sqlcmd in terminal and then we are going to hit enter. Below is the terminal output if everything is working.

Microsoft (R) SQL Server Command Line Tool
Version 13.1.0007.0 Linux
Copyright (c) 2012 Microsoft. All rights reserved.

usage: sqlcmd            [-U login id]          [-P password]
  [-S server or Dsn if -D is provided] 
  [-H hostname]          [-E trusted connection]
  [-N Encrypt Connection][-C Trust Server Certificate]
  [-d use database name] [-l login timeout]     [-t query timeout]
  [-h headers]           [-s colseparator]      [-w screen width]
  [-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]
  [-c cmdend]
  [-q "cmdline query"]   [-Q "cmdline query" and exit]
  [-m errorlevel]        [-V severitylevel]     [-W remove trailing spaces]
  [-u unicode output]    [-r[0|1] msgs to stderr]
  [-i inputfile]         [-o outputfile]
  [-k[1|2] remove[replace] control characters]
  [-y variable length type display width]
  [-Y fixed length type display width]
  [-p[1] print statistics[colon format]]
  [-R use client regional setting]
  [-K application intent]
  [-M multisubnet failover]
  [-b On error batch abort]
  [-D Dsn flag, indicate -S is Dsn] 
  [-X[1] disable commands, startup script, environment variables [and exit]]
  [-x disable variable substitution]
  [-? show syntax summary]

Finally we ready to user our SQL Server 2017 in Ubuntu 17.04

Create your first database in SQL Server 2017

At this time we are not ready for a remote SQL Server 2017 connection. Let’s first test our SQL Server 2017 server connection locally. In terminal run below command to connect your SQL Server 2017 instance

sqlcmd -S localhost -U SA -P '******'

Here ****** is your system administration password. If your connection parameters are correct, the following image shows, How your terminal looks after a successful connection.

Now for creating your first database execute below command in terminal and hit enter

CREATE DATABASE vLemonn_Test_DB;

 

 

Is our database is created? No. If you are going to open another terminal and execute USE Database command it is going to fail.

Why? For completing our command we need to type GO and then enter. So type GO in our first terminal where we enter Create Database command.

Finally, our first database is created successfully. Now, what next. In our next article, we are going to learn about SQL Server Management Studio alternative for Ubuntu 17.04. Also, we are going to enable port 1433 so we can connect to our SQL Server 2017 remotely.

Watch above steps in action. Following is the video tutorial demonstrating all the above steps.

What we are going to cover next

  1. Enable remote Connection for our SQL Server Instance.
0 Comments
Leave A Comment

Please login to post your valuable comments.

Join the newsletter

Get the latest vLemonn news first

share