MS SQL is a relational database system by Microsoft that was open-sourced in 2016. In this guide, I’ll take you through the steps to install MS SQL server on Ubuntu 18.04 Bionic Beaver Linux. In addition, We will look at how to create a database, add users, and lastly how to do daily backups for the databases.
Below are the minimum system requirements to run MS SQL on Ubuntu 18.04 server:
- Minimum memory of 1 GB
- CPU processor with a minimum speed of 1.4 GHz. But the recommended is >= 2 GHz
- SQL Server requires a minimum of 6 GB of available hard-disk space
Install MS SQL Server on Ubuntu 18.04
Follow the steps below to install and configure MS SQL database server on Ubuntu 18.04:
Step 1: Update system
As usual, we ensure all system packages are updated before adding any new packages:
sudo apt-get update sudo apt-get upgrade
If you have kernel updates done, ensure a reboot is done for the system to boot into a new kernel.
Step 2: Import the public repository GPG keys:
Add GPG key for the system to trust MS SQL apt repository packages:
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
Step 3: Add Microsoft SQL Server Ubuntu repository:
Add SQL server apt repository to your Ubuntu 18.04 system.
echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod xenial main" | sudo tee /etc/apt/sources.list.d/mssql.list
Step 4: Update package list and install mssql-server package:
Now run the following commands to install SQL Server:
sudo apt-get update sudo apt install libcurl3 sudo apt-get install -y mssql-server
The output is similar to below:
If you encounter error “mssql-server : Depends: openssl (<= 1.1.0) but 1.1.0g-2ubuntu4.1 is to be installed“. Downgrade the version of openssl installed on your system and re-install the mssql server.
$ wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.2g-1ubuntu4_amd64.deb $ sudo dpkg -i openssl_1.0.2g-1ubuntu4_amd64.deb $ apt-get -y install mssql-server
When the installation is done, proceed to set root user password by running initial setup
/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 PATHin the ~/.bashrc file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
Step 5: Install MS SQL tools and unixODBC plugin
Run the commands:
sudo apt-get update sudo apt-get install mssql-tools unixodbc-dev # sqlcmd -S localhost -U SA Password: 1> create database testDB;
Get a list database: