1. Overview
Microsoft SQL Server is a relational database offering from Microsoft. Unlike Mysql and PostgreSQL, it is not open source although you can use Developer and Express edition for free. In this tutorial, we’re going to install Microsoft SQL Server (mssql) 2019 Express edition on ubuntu 20.04. These same steps can also be applied for installing the Microsoft SQL Server on ubuntu 18.04.
2. Prerequisite
Before we start to install the Microsoft SQL Server (mssql). You’ll need to have either Ubuntu 18.04 or Ubuntu Server 20.04 with sudo access enabled. If you haven’t already installed Ubuntu, please refer to this tutorial How To Install Ubuntu Server 20.04 to install the latest LTS release of Ubuntu.
3. Add mssql repository
Since mssql is not available in Ubuntu default repositories. We first need to add the mssql repositories. run the following command in a terminal to install the mssql.
Import Microsoft public repository GPG keys:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
Register the mssql Ubuntu repository:
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"
If you get add-apt-repository: command not found, run this command to install software-properties-common.
sudo apt install software-properties-common
4. Install mssql
Once you have completed adding repository, Run the following command to install mssql server.
sudo apt-get update
sudo apt-get install -y mssql-server
5. Configure mssql
After you’re done installing the package. run mssql-conf-setup and follow the onscreen prompts to set the password and choose the edition of mssql as shown below.
sudo /opt/mssql/bin/mssql-conf setup
unixbin@mssql-server:~$ sudo /opt/mssql/bin/mssql-conf setup usermod: no changes Choose an edition of SQL Server: 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) - CPU Core utilization restricted to 20 physical/40 hyperthreaded 7) Enterprise Core (PAID) - CPU Core utilization up to Operating System Maximum 8) I bought a license through a retail sales channel and have a product key to enter. Details about editions can be found at https://go.microsoft.com/fwlink/?LinkId=2109348&clcid=0x409 Use of PAID editions of this software requires separate licensing through a Microsoft Volume Licensing program. By choosing a PAID edition, you are verifying that you have the appropriate number of licenses in place to install and run this software. Enter your edition(1-8): 3 The license terms for this product can be found in /usr/share/doc/mssql-server or downloaded from: https://go.microsoft.com/fwlink/?LinkId=2104294&clcid=0x409 The privacy statement can be viewed at: https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409 Enter the SQL Server system administrator password: Confirm the SQL Server system administrator password: Configuring SQL Server... The licensing PID was successfully processed. The new edition is [Express Edition]. ForceFlush is enabled for this instance. ForceFlush feature is enabled for log durability. Created symlink /etc/systemd/system/multi-user.target.wants/mssql-server.service → /lib/systemd/system/mssql-server.service. Setup has completed successfully. SQL Server is now starting. unixbin@mssql-server:~$
check status of mssql:
systemctl status mssql-server
If mssql-server is not already running, run the following commands in terminal to enable and start the database service.
sudo systemctl enable mssql-server
sudo systemctl start mssql-server
sudo systemctl status mssql-server
6. Configure firewall
Open the SQL Server TCP port 1433 on your firewall by running the following commands in your terminal.
sudo ufw allow ssh
sudo ufw allow 1433/tcp
sudo ufw enable
While running the last command sudo ufw enable system presents with the warning as shown below. Accept the warning as we’ve already allowed ssh in the firewall.
unixbin@mssql-server:~$ sudo ufw enable Command may disrupt existing ssh connections. Proceed with operation (y|n)? y Firewall is active and enabled on system startup unixbin@mssql-server:~$
7. Connect to SQL server
Download and Install SSMS. After installation is complete launch the SSMS and enter the credentials as you previously configured.
Wait for the connection to be established, After the connection is established you are now ready to use the Microsoft SQL Server running on ubuntu.
8. Conclusion
You have successfully deployed Microsoft SQL Server on Ubuntu 20.04. Please let us know how the installation went for you? also, feel free to share your feedback and comments.