Exciting mater is that we’re going to install Microsoft SQL Server on Ubuntu Linux. I’ve been working on SQL Server from last fourteen years. Many times, I’m to face many common words “Is your Application database can be installed on Linux platform?”, need additional licensing cost to buy OS for database server and Database server installation on Linux is more secure, … etc. Some time I feel people are not so well-informed about Linux OS and commands. It’s treated as mysterious island and fearful then Windows. Few people’s assumption or mindset is database server installation on Linux is safer. But safety and security depends on many initiative that we should follow. In the Post “Ubuntu VM creation on Azure ” it was described how can we setup an Virtual Machine. Now were going towards the installation of SQL Server 2017 on Ubuntu.

1.       We’re using use Putty to connect our VM. For on premises, we need to configured and enabled internet connection.

Notes: PuTTY is a free and open-source terminal emulator, serial console and network file transfer application. It supports several network protocols, including SCP, SSH, Telnet, rlogin, and raw socket connection.

 2.  You can install it or run the executable file(exe). Initially we use Putty to access our Ubuntu VM. After that we can use xrdp as remote desktop tools. Now copy your VM IP address and put the IP address in the Host Name for IP address and press ‘Open’ button:

2.2
3. Login option will be appeared: Input user name and password
 2.2.1 Putty terminal
4. Install SQL Server we have to run ‘apt-get update’ in order to sync the package index files with the new source that we’ve just added. Import the public repository GPG keys
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
5. 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
 6. Run the following commands to install SQL Server:
sudo apt-get update
sudo apt-get install -y mssql-server
7. When the package installation will be finished, we have to run ‘mssql-conf’ setup and ensure we agree to accept the license term. Then Enter the SQL Server system administrator password. 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/mssql-conf setup

2.6

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

2.7

  1. Connect to the server from Linux we need to install the ‘mssql-tools’ package, which comes from a different repository than the one that we just set up. It can be found here:
sudo apt-get update
10. Re-run the installation command, this will upgrade the specific mssql-server package: sudo apt-get install mssql-server .Now need install sql server tools.

2.10

  1. Install the mssql-tools on Ubuntu.First Step Import the public repository GPG keys
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –
12 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
13 Update the sources list and run the installation command with the unixODBC developer package.
sudo apt-get update 
sudo apt-get install mssql-tools unixodbc-dev

System will ask you to do continue ? Press YES

2.13.1

  1. At the time of configuration mssql-tools ,License Acceptance term will be appear Press Yes

2.13.2

  1. Configuration msodbcsql option completion require your authentication of YES.

2.13.3

16. Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell. To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
  1. First of all, let’s see how this tool is called on your system. It might be called something like sqlcmd-13.0.1.0 or simply sqlcmd but it should be in /opt/mssql-tools/bin/ directory. Let’s see what we have there:
ls /opt/mssql-tools/bin/sqlcmd*
18. After you get the name of the tool you can create a symlink :
ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd

19. To allow remote connections, you may need to open the SQL Server TCP port on your firewall The default SQL Server port is 1433.
sudo ufw allow 1433/tcp
To (if need ) network service restart
sudo service network-manager restart
  1. Now we login to the server and execute simple sql
sqlcmd -S localhost -U SA 

Execute following SQL 

SELECT @@VERSION
2> GO