Install MS SQL Server 2022 on Debian 12

In this guide, we want to show you how to Install MS SQL Server 2022 on Debian 12 Bookworm. MS SQL Server, commonly called SQL Server, is a relational database management system developed by Microsoft. It is designed to store and retrieve data as requested by other software applications, which can run on the same computer or another computer across a network.

Now proceed to the following steps to start your SQL Server installation on Debian 12.

A Comprehensive Guide To Install MS SQL Server 2022 on Debian 12

Before you start your SQL server setup, you must access your server as a non-root user with sudo privileges. For this purpose, you can check the Debian 12 Initial Setup Guide.

Then, follow the steps below to complete this guide.

Step 1 – Add SQL Server GPG Key and Repository To Debian 12

First, you must add the SQL server GPG key to your Debian server. To do this, you can use the following curl command:

# curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg

Then, use the following command to add the SQL server 2022 repository:

curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list | sudo tee /etc/apt/sources.list.d/mssql-server-2022.list

Now run the system update:

sudo apt update

Note: If you receive a warning about the public key not being available, you can use the following command and then re-run the system update:

# curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
# sudo apt update

Step 2 – Command To Install SQL Server on Debian 12

At this point that you have added the required repository and GPG key, you can easily use the following command to install MS SQL Server:

sudo apt install mssql-server -y

Step 3 – SQL Server Setup on Debian 12

Once your installation is completed, use the command below to finish your setup process:

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

First, you need to choose a SQL server edition. In this guide, we select Developer Edition.

choose a SQL server edition

Then, accept the license agreement by pressing Yes.

SQL Server license agreement

Next, set up a strong password for the SQL server admin user and confirm it.

set up a strong password for the SQL server admin user

Once your setup is completed, you will get the following output:

SQL Server Finish setup on Debian 12

Step 4 – Check MS SQL Server Status on Debian 12

At this point, you can confirm that your SQL server is active and running on your system. To do this, run the command below:

sudo systemctl status mssql-server --no-pager
Check MS SQL Server Status on Debian 12

Step 5 – Installing SQL Server 2022 Command Line Tools on Debian 12

At this point, you can easily install the CLI tools for SQL server. To do this, import the GPG key with the command below:

curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc

Then, add the repsoitory list:

curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list

Finally, run the system update and install command line tools:

# sudo apt update
# sudo apt install mssql-tools18 unixodbc-dev -y

Accept license agreement during the installation.

install the CLI tools for SQL server

Step 6 – Configure Environemnt Variable Path for sqlcmd and bcp (Optional)

At this point, you can add the /opt/mssql-tools18/bin/ to your PATH environment variable in a bash shell.

For login sessions, you can use:

echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bash_profile

For interactive/non-login sessions, you can use:

# echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
# source ~/.bashrc

Step 7 – Connect To SQL Server 2022

To verify your SQL server is working correctly, you can connect to it locally by using the folwloing comamnd:

sqlcmd -S localhost -U sa -P '<YourPassword>'

Note: If the connection doesn’t succeed, you can add the -No option to sqlcmd to specify that encryption is optional, not mandatory.

sqlcmd -S localhost -U sa -N -P '<YourPassword>' 

Once you lanched your shell, you can check your system databases with the following commands:

1> select name,database_id from sys.databases; 
2> go 
check your system databases with MS SQL Server

To end your session, you can use:

exit 

Conclusion

Remember, while SQL Server runs on Linux, there are differences in file paths, scripts, and tools compared to Windows. Always refer to the Linux-specific documentation for MS SQL Server for guidance. Hope you enjoy it.

Also, you may like to read the follwoing articles:

Monitor Ubuntu Server with Glances Remotely

Fix Error SMTP Cannot Find Mail Address in Ubuntu

HAproxy Load Balancing on AlmaLinux 9

Run Automatic Updates with dnf-automatic on RHEL 8 & 9

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular