Install sqlserver in wsl2 and ubuntu 22.04
- 1 minutes read - 182 wordsI searched web, first several links in SERP are not the offical one from microsoft. I tried them and failed to install mssql due to errors Error: 'deb [arch=amd64 https://download.docker.com/linux/ubuntu \ xenial \ stable' invalid] or Can’t install MS SQL Server on Ubuntu 21.10. At last I follow the instruction from microsoft. I successfully installed mssql server in my wsl+ubuntu22.04 environment.
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
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
sudo apt-get update
sudo apt-get install -y mssql-server
sudo /opt/mssql/bin/mssql-conf setup
systemctl status mssql-server --no-pager
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo apt-get install mssql-tools18 unixodbc-dev
#as Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server:SSL Provider: error:0A000086:SSL routines::certificate verify failed:self-signed certificate, add -C options
sqlcmd -C -S localhost -U sa -P '<YourPassword>'
Another thing need to notice is that Microsoft ODBC Driver 18 for SQL Server:SSL Provider: error:0A000086:SSL routines::certificate verify failed:self-signed certificate. I used the following connection string options to resolve the issie.
"TraceLogging": "Server=localhost;Database=testdb;Integrated Security=False;Encrypt=false;TrustServerCertificate=Yes;User ID=sa;Password=aaaa;"