DEV Community

Cover image for How To Install SQL Server on Ubuntu
Hasan Aboul Hasan
Hasan Aboul Hasan

Posted on

How To Install SQL Server on Ubuntu

In this post, we'll learn How to Install Microsoft SQL Server on Ubuntu VPS Server. and we will see how to connect and manage it remotely using SQL Server Management Studio on windows.

Let's Get a VPS Server

In this tutorial, I will use VULTR, and if you wanna follow with me a test, you can use this link to get 100$ free credits for two weeks!

Create a new VPS
vultr create server

  1. Select Cloud compute.
  2. Select any region you want.
  3. Select Ubuntu as the OS.
  4. Enter server name (anything you want)
  5. Click deploy

VULTR will install, deploy, and prepare this Ubuntu Linux server in your account. And when it's finished, you will see the IP address, the username, and the password.

vultr vps

Great! we have an Ubuntu Server βœ… Let's Start the installation.

we will be using putty SSH client to connect and manage our server.

Open putty, enter the server IP, and connect:
putty connection

Enter "root" as the user name, and get the password from Vultr Dashboard.

Install SQL Server

The first command is wget command:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

Adding SQL server package
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)"

NOTE: This may change depending on the Ubuntu version you are working with.

Update SQL Server
sudo apt-get update

sudo apt-get install -y mssql-server

*Configuration command *
sudo /opt/mssql/bin/mssqql-conf setup

Now Continue the wizard:

  1. Select your edition, I will go with express.
  2. Accept Terms (Y)

Set The SQL Server Password

And Congratulations! SQL Server is now starting πŸŽ‰

SQL Server Run Check Command:
systemctl status mssql-server --no-pager

Sql server on ubuntu

And it's running perfectly.πŸš€πŸš€πŸš€

Managing With SQL Server Management Studio

Setting up SQL Server Remote Port

in putty, run this command:
Sudo iptables -A INPUT -p tcp –dport 1433 -j ACCEPT

Now we can connect to SQL server from our local PC.

Open SQL Management Studio, Enter your server IP.
sql server management studio

Enter "sa" for the user name, and enter your sql server password that you chose in the setup.

Connect!
Yay, it did work!!!πŸ‘Œ

I'll be answering questions in the comments below if you have any.


Top comments (0)