Open In App

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 for educational purposes. This edition is used by Students, hobbyists, and startups to develop projects that do not require advanced features of SQL Server. It can also be used for any production database that is sized at or below the current SQL server. It has 10 GB of maximum database size and other important limits. In this article, we will learn how to install SQL Server Express in Linux.

Installing SQL Server Express in Linux

Follow the below steps to install SQL Server Express on ubuntu:



Step 1: Import the public repository GPG keys:

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



Step 2: Add MS-SQL Server repository:

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

Step 3: Install the Server using the following commands.

sudo apt update && sudo apt install -y mssql-server

Installing required packages…

Step 4: Configure the Server using the following command:

sudo /opt/mssql/bin/mssql-conf setup

While configuring the Server, choose ” 3 “ to install SQL Express Server as shown below and set up an administrator password.

Step 5: Verify that the server is running:

Step 6: Install the SQL Server command-line tools. So first we add tools repository using the following command:

curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

Now Install the required CLI tools:

sudo apt update && sudo apt install -y mssql-tools unixodbc-dev

Now we make a symbolic link of sqlcmd  in /usr/local/bin :

sudo ln -s /opt/mssql-tools/bin/sqlcmd /usr/local/bin

At this point your installation is successful.

Create a new Database

Step 1: Connect locally to your MS SQL Express Server as the user SA:

sqlcmd -S localhost -U SA

Step 2: Create a database:

CREATE DATABASE <database name>

GO

Step 3: Verify the database creation:

SELECT name FROM sys.databases

GO

Note: To execute a command properly or commit a transaction, you must type GO on a new line to execute previous commands.

Article Tags :