How To Install SQL Server on Ubuntu Linux Server.

Install Microsoft SQL Server Database on Ubuntu Linux Server

Table of Contents

Spread the love

In this post, we'll learn How to Install SQL Server on Ubuntu Linux Server. We will also practice how to connect and manage it remotely from SQL Server Management Studio.

let's see the whole process step by step.

Install SQL Server on Ubuntu Linux Server (Detail With Commands)

I made a Video, about Installing Microsoft SQL Server on Ubuntu Linux Server. I recommend you check it out if you're into Video Content.

Let's Do it!

If you want to follow up with us and learn practically (and that's what you should do), then you need to get a VPS server.

Ubuntu VPS Server (Setup)

In this tutorial, I will use VULTR 

install sql server on ubuntu

Create a new VPS.

You can use my link to get free credits of ~100 dollars for 2 weeks to learn with us and test totally for free.

Click on the plus icon, to deploy a new server.

install sql server on ubuntu

 Select Cloud compute.

install sql server on ubuntu

Select any region you want.

install sql server on ubuntu

I will select Ubuntu 20.04 and select the size you want. 

install sql server on ubuntu

And then simply enter a server name. In my case, I will say SQL server test.

 And click deploy 

install sql server on ubuntu

Now you will have a VPS server in a couple of seconds or minutes.

VULTR will install, deploy, and prepare this Ubuntu Linux server in your account.

When it's finished you will see the IP address, the username, and the password.

ubuntu server vultr

Ubuntu Linux Server (Putty Setup)

Now, go to a website called putty.org and download and install putty SSH Client to connect to our server. 

install putty

You have to Download it, Depending on your architecture. In my case, it's x 64.

download putty

And now go and open putty to connect to our server.

connect putty

Get the IP address of the server from your Vultr dashboard.

vultr vps

Put it here and click open. 

Type ‘root' 

root login putty

Copy the password.

And paste inside putty (to paste it just right-click on your mouse it will be hidden, but don’t worry it's there)

putty hidden password

Press enter and you'll be inside your server.

putty vultr

Install SQL Server

Let's now start installing SQL server (it's only five commands). But, if you want more commands, help, and resources. You can check this Official Microsoft Guide out.

WGET Command

The first command is wget command, to get the keys. Here it is:

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

Paste and Press enter.

Adding SQL server package

Then I will add the SQL server package to my server. Here it is for Ubuntu 20.04:

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. Go here and select the command for your Specific Version of Ubuntu.

To know your Ubuntu Version, Find your version when we completed the server Setup with Putty above. 

ubuntu version putty

Command number two finished 

Update SQL Server

Then simply update and install SQL server with these two commands

install sql on ubuntu
sudo apt-get update 

And

install sql on ubuntu
sudo apt-get install -y mssql-server

Or

sudo apt-get install mssql-tools

Press Enter and Wait. And as you can see, it works perfectly!

install sql on ubuntu

Now it's time for the last command.

Configuration command 

Paste this one 

sql configuration on ubuntu
sudo /opt/mssql/bin/mssqql-conf setup

Press Enter to Run the setup and now, it will tell you to pick the edition.

install sql on ubuntu

Select what you want. I will go with express which is three, 

install sql on ubuntu

and press enter.

Now yes to accept license terms 

install sql on ubuntu

Type ‘yes’ and press enter.

Setting SQL Server Password

Now enter a strong password for your database.

Just Type and press ENTER, to set and confirm it. You won’t be able to see it, but it’s there.✔

And Congratulations! SQL Server is now starting. 

SQL Server Run Check Command

Let's check if the service is running with this simple command.

systemctl status mssql-server --no-pager

And it's running perfectly.????????????

Managing With SQL Server Management Studio

Now to create/manage databases, add tables and do the cool stuff. You have two options.

1. use the cli command-line tools or

2. use SQL server management studio 

I believe it's easier to use SQL server management studio. As we have an interface, especially for beginners.

sql server management studio

Setting up SQL Server Remote Port

So simply inside your server again we need to open a port.

SQL server remote port., which is TCP 1433

how to do this?

Simply paste this command( IP tables )

open sql server port putty
Sudo iptables -A INPUT -p tcp –dport 1433 -j ACCEPT

That's it 

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

Let's test it.

I will open it here, and click on ‘create a new connection' 

Let's paste the IP. copy the IP, from VULTR dashboard.

vultr ip

Paste IP here.

sql server connection
Install Microsoft SQL Server Database on Ubuntu Linux Server

SQL Server Authentication.

sql server connection

Enter ‘sa‘ for login and enter the password you used in the installation.

Click connect.

sql server connection

Yay, it did work out!

Perfect!

Now, we are inside our server.

You can create databases, add tables or work on queries. Do whatever you want.

manage sql server with GUI

Now, this approach may be a little bit slow, but easy for beginners.

What's Next?

Now it's time to implement a real application with a real SQL server database using .net core app with a database and learn how to host it.

I believe this Blog Post is for you right now.

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

Take Care!


Spread the love