Learn how to Set up and Set Up Microsoft SQL Server on Ubuntu

One of the critical parts of most software systems is a database server. A database server is a program used to store and manage data for other software applications.

This guide shows you how to install Microsoft SQL Server on Ubuntu 20.04. SQL Server is one of the most robust and widely used database servers in IT. A native SQL Server for Linux has been available since 2017, while earlier versions of SQL Server were only available for the Windows operating system.

Install SQL Server 2019

First, import the public GNU Privacy Guard (GnuPG) key from Microsoft into your list of trusted keys so that your system establishes an encrypted and secure connection when downloading SQL Server from Microsoft repositories.

Use the following command to import the GnuPG key.

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo add apt-key –

Now you should register the Microsoft SQL Server Ubuntu Package Repository for SQL Server 2019. This is the repository from which you download the SQL Server 2019 for Ubuntu Linux.

sudo add-apt-repository "$ (wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)"

Note: Replace the version number i.e. April 20 in the command above with the LTS version of Ubuntu you are using. For example, if you're using Ubuntu 18.04, replace /ubuntu/20.04 With /ubuntu/18.04.

Before installing SQL Server, update your list of repositories to receive the changes for the newly added repository.

sudo apt update

Finally, install the SQL Server package using the following command.

sudo apt install -y mssql-server

Configure your server

Once the installation is complete, you should proceed to configure your SQL Server instance by setting up the system administrator (SA) password.

Run the following command to start configuring your SQL server.

Set up sudo / opt / mssql / bin / mssql-conf

The first prompt in the configuration prompts you to select the edition of SQL Server that you want to install. Both paid and free editions are available. This guide uses the SQL Server Express edition, which is option 3. Enter your option and press Enter.

The system will then show you a link to the license terms and a prompt to accept the terms. Enter Yes to agree to the terms and proceed with the installation.

The next step is to set the system administrator (SA) password for your SQL Server instance. Use a strong and secure password to prevent your data from being compromised.

You can check the status of your SQL Server service with the systemctl Command.

systemctl status mssql-server

Install Azure Data Studio

There are several ways to interact with SQL Server databases on Linux using the command line or a GUI application. the latter is used in this manual.

In this section, you install Azure Data Studio, a simple cross-platform database management tool. You can use Azure Data Studio to query, design, and manage your database on-premises or in the cloud.

First, load the Azure Data Studio Debian package onto your Downloads Folder.

Download: Azure Data Studio

Install the Azure Data Studio DEB package using the following command.

sudo apt install ~ / Downloads / azuredatastudio-linux-1.30.0.deb

Note that the command assumes that the Downloads Folder contains the DEB package. So make sure you are using the correct folder location.

Related: How to Install a DEB File in Ubuntu?

Run Azure Data Studio

Once the above installation is complete, you can start Azure Data Studio from the terminal.


The Azure Data Studio splash screen looks like below.

To connect to a database server, click the New connection Link under the begin Section. You will then be asked to enter your database connection details.

Since the database you are connecting to is on your PC, you are using localhost as a server name. The default username is SA. Enter the password that you used when you configured your SQL Server instance. Finally click on the Connect Button.

More information: What is 127.0 0.1, localhost, or a loopback address?

Your Connection details Screen should be similar to the one shown below.

Once connected, the system will list all of your databases in the left pane. You can now manage your databases from this screen.

Why use a SQL-based database?

This guide showed you how to install Microsoft SQL Server, a relational database system, on Ubuntu Linux. You have also installed Azure Data Studio to make it easier to manage your databases. SQL-based databases are easy to manage, very scalable, and are widely used by database administrators.

Alternatives to SQL-based databases known as NoSQL databases are now becoming increasingly popular as they use object-oriented schemes to organize data. Some notable NoSQL databases are Cosmos DB and MongoDB.

SQL vs. NoSQL: What's the Best Database for Your Next Project?

Choosing a database type can be difficult. Should you choose SQL or NoSQL?

Continue reading

About the author

Mwiza Kumwenda
(25 articles published)

Mwiza is a professional developer of software and writes extensively on Linux and front-end programming. His interests include history, economics, politics, and corporate architecture.

By Mwiza Kumwenda

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

Leave a Reply

Your email address will not be published. Required fields are marked *