How to Install and Connect to SQL Server on an Ubuntu VM

This documentation provides a step-by-step guide to installing Microsoft SQL Server on an Ubuntu virtual machine (VM) and then connecting to it remotely using SQL Server Management Studio (SSMS).


1. Install SQL Server on the Ubuntu VM 🖥️

Follow these commands in order on your Ubuntu VM.

  1. Add the Microsoft GPG key: This command securely imports the key used to verify Microsoft packages.Bash

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

image.png

  1. Add the Microsoft repository: This adds the official repository for SQL Server 2022 to your package manager's sources list.Bash

    sudo add-apt-repository "$(curl <https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list>)"

curl [<https://packages.microsoft.com/config/ubuntu/22.04/prod.list>](<https://packages.microsoft.com/config/ubuntu/22.04/prod.list>) | sudo tee /etc/apt/sources.list.d/mssql-tools.list

image.png

  1. Update the package list: This refreshes the list of available packages.Bash

    sudo apt-get update

    image.png

  2. Install SQL Server: This command downloads and installs the SQL Server engine.Bash

    sudo apt-get install -y mssql-server

    image.png

  3. Run the setup script: This script prompts you to accept the license terms, choose the edition, and set a strong password for the sa (system administrator) user.Bash

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

image.png

after selecting 3

image.png

here you need to write password: must meet all the criteria, include number, special character, 8 characters and Lowercase and higher case

image.png