SQL Server on Debian
Not only have Microsoft made .NET available for Linux, they also ported SQL Server. This time, I want to install Microsoft SQL Server 2022 on Debian 12 (bookworm).
Install SQL Server
Unfortunately, Microsoft has not made a SQL Server package for Debian. But they have made one for Ubuntu, and Ubuntu 22.04 (Jammy Jellyfish) is close enough to Debian 12 (bookworm) to make this work.
Add the package feed by creating the following file:
/etc/apt/sources.list.d/mssql-server.list
deb [arch=amd64] https://packages.microsoft.com/ubuntu/22.04/mssql-server-2022 jammy main
We also need the Microsoft package key to validate packages. This must be downloaded and installed in the correct place.
wget https://packages.microsoft.com/keys/microsoft.asc
sudo mv microsoft.asc /etc/apt/trusted.gpg.d/
Now try and install SQL Server.
sudo apt-get update
sudo apt-get install mssql-server
Setup SQL Server
Once SQL Server has been successfully installed it needs to be setup.
sudo /opt/mssql/bin/mssql-conf setup
This will ask for which edition you want to run. I chose Express, which is adequate for most purposes.
When the setup is complete SQL Server should start automatically. Run the following command to check that this is the case:
sudo systemctl status mssql-server
Connect to SQL Server
I prefer to do my database administration from Windows with SQL Server Management Studio. But any SQL client will do. There is nothing special about connecting to SQL Server on Linux compared to any other database server.
Finally, run the following query to see that everything is working:
SELECT @@VERSION
In my case this displays: Microsoft SQL Server 2022 (RTM-CU10) (KB5031778) - 16.0.4095.4 (X64) Oct 30 2023 16:12:44 Copyright (C) 2022 Microsoft Corporation Express Edition (64-bit) on Linux (Debian GNU/Linux 12 (bookworm))