How to Install and Use MS SQL Server on Linux?
Last Updated :
29 Apr, 2025
Microsoft SQL Server is a relational database management system (RDBMS) that supports a broad range of transaction processing, business intelligence, and analytics applications. Along with Oracle Database and IBM’s DB2, Microsoft SQL Server is one of the three market-leading database technologies.
Microsoft SQL Server, like other RDBMS applications, is based on SQL, a structured programming language used by database administrators (DBAs) and other IT professionals to manage databases and query the information they hold. Transact-SQL (T-SQL), a Microsoft SQL implementation that applies a number of proprietary programming extensions to the regular language, is bound to SQL Server.
Why Use Microsoft SQL Server on Linux?
Running SQL Server on Linux is good option because it brings the power of a leading RDBMS together with the flexibility and openness of Linux. Here’s why it’s great:
- Versatile: Can be used for small projects or big enterprise systems.
- Powerful: Can handle transaction processing, business intelligence, and analytics just as well.
- Linux-Friendly: Microsoft has created SQL Server cross-platform compatible for Linux operating systems like Ubuntu and therefore made more accessible to greater numbers of users.
- Scalable: Can grow with increasing requirements, right from a lone database to advanced systems.
Whether you’re a database administrator (DBA), developer, or small business owner, SQL Server on Linux is a reliable choice for handle data.
Installing Microsoft SQL Server on Linux (Ubuntu)
Ensure that the most current software package is installed on the system. This will require you to update and upgrade your system.
Step 1: Update Your System
Before installing anything, make sure your Ubuntu system is up to date to avoid compatibility issues. Open your terminal and run the below command:
sudo apt update && sudo apt upgrade
- sudo: Gives you admin privileges.
- apt update: Refreshes the list of available software.
- apt upgrade: Installs the latest versions of your software.

Installing and upgrading system
Step 2: Add Microsoft’s GPG Key
To trust Microsoft’s software, you need to add their GPG key to your system. This verifies that the software you’re downloading is legit. Run:
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
- wget: Downloads the key from Microsoft’s website.
- apt-key add: Adds the key to your system’s trusted list.

Adding key
Step 3: Add the Microsoft SQL Server Repositor
Next, tell your system where to find the SQL Server software by adding Microsoft’s official repository. Run below commands:
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-blockquoteview.list)"
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
- add-apt-repository: Adds the SQL Server repository for Ubuntu.
- curl: Fetches the repository for additional tools.
- tee: Saves the repository info to your system.


Note: If you’re using a different Ubuntu version (e.g., 20.04 or 22.04), replace 16.04 in the URLs with your version number. Check Microsoft’s official site for the correct link.
Step 4: Update and Install SQL Server
Now, update your package list again and install SQL Server along with its tools:
sudo apt-get update
sudo apt-get install mssql-server mssql-tools unixodbc-dev -y
- mssql-server: The core SQL Server software.
- mssql-tools: Includes tools like sqlcmd for interacting with the database.
- unixodbc-dev: A library for database connectivity.
- -y: Automatically agrees to installation prompts.


After installation, set up SQL Server by running the configuration script:
sudo /opt/mssql/bin/mssql-conf setup

Select 2 for edition:

Type Yes:

Set password:

Now accept the license:

Using Microsoft SQL Server on Linux
Now that SQL Server is installed, let’s log in and create a simple database to see it in action. We’ll use sqlcmd, a command-line tool included with mssql-tools, to interact with the server.
Step 1: Log in to SQL Server
We’ll log in to the server and build the Fabrics database. The password you used when you first installed the package must be followed by the -P switch:
sqlcmd -S localhost -U SA -P 'YourPassword'
- -S localhost: Connects to SQL Server on your computer.
- –U SA: Uses the SA (admin) account.
- -P ‘YourPassword’: Enter the password you set (replace YourPassword with your actual password).

Step 2: Create a Database
Let’s create a database called testdb. At the 1> prompt, type:
CREATE DATABASE testdb

Then type go:
GO

Step 3: Exit sqlcmd
To leave the sqlcmd tool, type:
exit

Conclusion
Microsoft SQL Server is a powerhouse for managing data, and running it on Linux makes it even more accessible. In this you’ve learned how to install SQL Server on Ubuntu, set it up, and create your first database using sqlcmd. You’ve also seen how SQL and Transact-SQL (T-SQL) make it easy to work with data for transaction processing, business intelligence, and analytics.
Similar Reads
How to install SQL Server Agent on Linux?
SQL Server Agent is a Microsoft Windows service that runs SQL Server jobs, which are scheduled administration activities. SQL Server Agent stores job information in SQL Server. One or more job steps can be found in a job. Each phase has its own set of tasks, such as backing up a database. Installing
2 min read
How to Install SQL Server Agent on MacOS?
SQL Server is a Relational Database Management system(RDBMS) developed by Microsoft. SQL Server consists of two major components namely Database Engine and SQLOS. Along with the creation and execution of triggers Database Engine also processes queries and manages Database fields. SQLOS provides serv
2 min read
How to Install SQL Server on MacOS?
In this article, we are going to learn "How to install SQL Server Express in MacOs". Now, before we jump to the setup part, Let's learn about SQL Server Express. So, SQL Server Express is an open-source RDBMS database management system i.e. Relational database management system which is used to stor
5 min read
How to Install SQL Server Agent on Windows?
SQL Server Agent is a component of Microsoft SQL Server. It schedules jobs and handles other automated task on a database.This windows service can automatically start when we boot up the system or set it up manually. SQL Server Agent enables us to automate all the task which are repetitive in nature
3 min read
How to Install SQL Server on Azure VM?
Microsoft Azure provides us with multiple database services which help us to run popular relational database management systems, like MySQL, SQL Server, and PostgreSQL in the cloud. We can use an SQL server on Azure Virtual machines by running a virtual machine in Azure and installing an SQL server
5 min read
How to Install SQL Server Express in Linux?
Microsoft SQL Server Express is a feature-limited edition of Microsoft's SQL Server relational database management which is free to download, distribute, and use. It is used for creating or developing small-scale applications. It has been published since the SQL Server 2005. Microsoft provides it fo
2 min read
How to Uninstall an Instance of SQL Server?
SQL Server is a Relational Database Management system that was developed and marketed by Microsoft. In this article, we will look into how to uninstall an instance of SQL Server setup: Prerequisites:To uninstall SQL Server, you need to have local administrator permissions.Back up your data. You coul
2 min read
How to Install SQL Server Client on Windows?
The Client / Server Application is a computer program that allows users to access what is stored on the server. Of course, both computers can be workstations running the same type of operating system. In most network environments, the server contains a database that requires users to access this dat
2 min read
How to Stop MySQL Server on Windows and Linux?
MySQL is one of the most popular open-source relational database management systems. Whether we are managing a small development setup or a production environment knowing how to start and stop MySQL servers is essential. In this guide, we will learn about the steps to start and stop MySQL servers on
3 min read
How to Install SQL Workbench For MySQL on Linux?
MySQL Workbench is a visual database design tool that integrates SQL development, administration, database design, creation, and maintenance into a single integrated development environment for the MySQL database system. It was first released in 2014. It is owned by Oracle Corporation. It supports W
2 min read