Share your love
Comprehensive Guide To 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 provided by the Orcacore website to Install MS SQL Server 2022 on Debian 12.
Table of Contents
Easy Steps 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 Install MS SQL Server 2022 on Debian 12.
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.

Then, accept the license agreement by pressing Yes.

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

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

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

Step 5 – Installing SQL Server 2022 Command Line Tools on Debian 12
At this point, you can easily install the CLI tools for the 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 the license agreement during the installation.

Step 6 – Configure Environment 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 following command:
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 launched your shell, you can check your system databases with the following commands:
1> select name,database_id from sys.databases;
2> go

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 following articles:
Monitor Ubuntu Server with Glances Remotely
Fix Error SMTP Cannot Find Mail Address in Ubuntu