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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/1-8-1024x202.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/2-5.png)
Select Cloud compute.
![install sql server on ubuntu](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/3-9.png)
Select any region you want.
![install sql server on ubuntu](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/4-9-1024x276.png)
I will select Ubuntu 20.04 and select the size you want.
![install sql server on ubuntu](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/5-9.png)
And then simply enter a server name. In my case, I will say SQL server test.
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/6-7.png)
And click deploy
![install sql server on ubuntu](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/7-10.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/8-8.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/9-9-1024x211.png)
You have to Download it, Depending on your architecture. In my case, it's x 64.
![download putty](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/10-7.png)
And now go and open putty to connect to our server.
![connect putty](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/11-8.png)
Get the IP address of the server from your Vultr dashboard.
![vultr vps](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/12-7.png)
Put it here and click open.
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/13-5.png)
Type ‘root'
![root login putty](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/14-5.png)
Copy the password.
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/15-4.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/16-3.png)
Press enter and you'll be inside your server.
![putty vultr](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/17-3.png)
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.
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/18-4.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/19-3.png)
Command number two finished
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/20-4.png)
Update SQL Server
Then simply update and install SQL server with these two commands
![install sql on ubuntu](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/21-2.png)
sudo apt-get update
And
![install sql on ubuntu](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/22-3.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/23-3.png)
Now it's time for the last command.
Configuration command
Paste this one
![sql configuration on ubuntu](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/24-2.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/25-2.png)
Select what you want. I will go with express which is three,
![install sql on ubuntu](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/26-3.png)
and press enter.
Now yes to accept license terms
![install sql on ubuntu](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/27-2.png)
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.✔
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/28-2.png)
And Congratulations! SQL Server is now starting.
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/29-1.png)
SQL Server Run Check Command
Let's check if the service is running with this simple command.
systemctl status mssql-server --no-pager
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/31-1.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/32-1.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/33-1.png)
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'
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/34-1.png)
Let's paste the IP. copy the IP, from VULTR dashboard.
![vultr ip](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/35-1.png)
Paste IP here.
![sql server connection](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/36-2.png)
SQL Server Authentication.
![sql server connection](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/37-1.png)
Enter ‘sa‘ for login and enter the password you used in the installation.
Click connect.
![sql server connection](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/38-1.png)
Yay, it did work out!
![](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/39.png)
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](https://learnwithhasan.10web.me/wp-content/uploads/2022/06/40.png)
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!