
This article provides a guide for how to install Microsoft SQL Server on Ubuntu VPS.
What is Microsoft SQL Server?
Microsoft SQL Server is a relational database management system (RDBMS) developed by Microsoft. It is used to store, retrieve, manage, and analyze data in a structured way using SQL (Structured Query Language).
🔑 Key Features:
- SQL Engine: Handles querying and data manipulation using T-SQL (Transact-SQL).
- SSMS (SQL Server Management Studio): A GUI tool to manage databases.
- Security: Supports encryption, role-based access, and auditing.
- High Availability: Offers features like Always On Availability Groups, failover clustering, and replication.
- Integration Services: ETL (Extract, Transform, Load) operations via SQL Server Integration Services (SSIS).
- Reporting Services (SSRS): Tools to create and deliver reports.
- Machine Learning Services: Allows R and Python integration for advanced analytics.
- Support for JSON, XML, Spatial Data, and Graph Databases.
🖥️ Common Use Cases:
- Enterprise Applications (e.g., ERP, CRM)
- Business Intelligence and Reporting
- Data Warehousing
- E-commerce Platforms
- Web Applications
📦 Editions Available:
| Edition | Description |
|---|---|
| Express | Free entry-level version for small-scale applications. |
| Developer | Free full-featured version for development and testing. |
| Standard | Core database functionality for mid-tier applications. |
| Enterprise | Full feature set including advanced analytics, scalability, and HA. |
| Web | Affordable version for web hosting providers. |
🧩 Platforms Supported:
- Windows Server (primary OS)
- Linux (available since SQL Server 2017)
- Docker containers
Here’s a detailed step-by-step guide on How to Install Microsoft SQL Server on an Ubuntu VPS. This guide is applicable to Ubuntu 20.04, 22.04, and newer LTS versions.
🧰 Prerequisites
- Ubuntu VPS (Ubuntu 20.04 LTS or newer)
- SSH access with root or sudo privileges
- Minimum 2 GB RAM (Microsoft SQL Server requires at least 2 GB)
- Internet connection

Compare Ubuntu VPS Plans
How to Install Microsoft SQL Server on Ubuntu VPS
To install Microsoft SQL Server on Ubuntu VPS, follow the steps below:
-
📦 Import Microsoft GPG Key and Add SQL Server Repository
- Open an SSH terminal and log in to your Ubuntu VPS.
- Import the Microsoft GPG key:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
- Add the Microsoft SQL Server repository:
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/mssql-server-2022.list)"
- Update package lists:
sudo apt update
-
🛠 Install Microsoft SQL Server
- Install SQL Server:
sudo apt install -y mssql-server
- Run the configuration script:
sudo /opt/mssql/bin/mssql-conf setup
- During setup, you will:
- Choose the edition (e.g., Developer, Express)
- Accept the license terms
- Set a strong
SA(System Administrator) password
- Enable and start SQL Server:
sudo systemctl enable --now mssql-server
- Install SQL Server:
-
✅ Verify SQL Server Installation
Check if SQL Server is running:
systemctl status mssql-server
You should see
active (running)in green. -
🔧 Install Microsoft SQL Server Command-Line Tools (Optional but Recommended)
- Import the Microsoft GPG key and repository for tools:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list)" sudo apt update
- Install SQL tools:
sudo apt install -y mssql-tools unixodbc-dev
- Add tools to your path:
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
- Import the Microsoft GPG key and repository for tools:
-
🧪 Connect to SQL Server
Use
sqlcmdto connect:sqlcmd -S localhost -U SA -P 'YourPasswordHere'
If successful, you’ll get a
1>prompt. Try a simple query:SELECT @@VERSION; GO
-
🔐 Configure Firewall (If UFW is Enabled)
If your server uses UFW (Uncomplicated Firewall), open port
1433:sudo ufw allow 1433/tcp
-
📤 Enable Remote Access (Optional)
To allow external clients to connect:
- Edit the Microsoft SQL Server config:
sudo nano /opt/mssql/mssql.conf
- Add (or edit) under
[network]:[tcp] tcpport=1433
- Restart the service:
sudo systemctl restart mssql-server
Make sure your VPS provider allows traffic on port
1433.
- Edit the Microsoft SQL Server config:
-
🧼 Troubleshooting Tips
Issue Solution Cannot connect with sqlcmdEnsure SQL tools are installed and SQL Server is running Login failed for user ‘SA’ Double-check password and ensure SA is enabled Port 1433 not accessible Check UFW, provider firewall, and SQL Server config
📚 Bonus: Create a Sample Database
Once connected:
CREATE DATABASE TestDB; GO USE TestDB; GO CREATE TABLE Inventory (id INT, name NVARCHAR(50)); GO INSERT INTO Inventory VALUES (1, 'Screwdriver'), (2, 'Hammer'); GO SELECT * FROM Inventory; GO
After we install Microsoft SQL server on Ubuntu VPS, let’s install Adminer on Ubuntu VPS so we can manage Microsoft SQL Server from a web-based GUI.
🌐 What is Adminer?
Adminer is a lightweight, single-file PHP web app that lets you manage databases from a browser—like a simpler, more secure alternative to phpMyAdmin.
✅ Works with: SQL Server, MySQL, PostgreSQL, SQLite, Oracle, and others
✅ No database client needed
✅ Simple installation (just one PHP file)
📦 Prerequisites
- Ubuntu VPS with Microsoft SQL Server installed
- Apache or Nginx web server
- PHP installed (7.4+ recommended)
⚙️ Step-by-Step: Install Adminer for Microsoft SQL Server
To install Adminer for Microsoft SQL Server on Ubuntu VPS, follow the steps below:
-
Install Web Server + PHP
For Apache:
sudo apt update sudo apt install -y apache2 php php-sybase
php-sybaseenables PHP to connect to Microsoft SQL Server via FreeTDS. -
Download Adminer
sudo mkdir -p /var/www/html/adminer cd /var/www/html/adminer sudo wget -O index.php https://github.com/vrana/adminer/releases/latest/download/adminer.php
-
Secure Permissions
sudo chown -R www-data:www-data /var/www/html/adminer sudo chmod -R 755 /var/www/html/adminer
-
Enable the Adminer Site (Apache only)
If you’re using Apache:
sudo systemctl restart apache2
You can now access Adminer at:
http://your-server-ip/adminer
-
Login to Microsoft SQL Server via Adminer
Use the following settings:
- System: Microsoft SQL Server
- Server:
localhost(or your IP) - Username:
SA(or your configured SQL user) - Password: (your password)
- Database: (optional: specify or leave blank to list all)
If connecting remotely, use the public IP or hostname and ensure port 1433 is open.
-
Secure Adminer (Highly Recommended)
-
Option 1: Restrict IP Access via
.htaccess(Apache)sudo nano /var/www/html/adminer/.htaccess
Order Deny,Allow Deny from all Allow from YOUR_IP_ADDRESS
-
Option 2: Password-protect with Basic Auth
sudo apt install apache2-utils sudo htpasswd -c /etc/apache2/.htpasswd youradminuser
Edit your site config or
.htaccessto include:AuthType Basic AuthName "Restricted Access" AuthUserFile /etc/apache2/.htpasswd Require valid-user
Then reload:
sudo systemctl reload apache2
-
✅ Adminer is Ready!
You can now:
- Run SQL queries
- Browse tables
- Create/modify users and databases
- Export/import data
All from your web browser.
🛠 Optional: Use Adminer Theme (for better UI)
wget -O adminer.css https://raw.githubusercontent.com/vrana/adminer/master/designs/pepa-linha/adminer.css
Adminer will auto-load adminer.css if placed in the same directory.

Compare Ubuntu VPS Plans
Conclusion
You now know how to install Microsoft SQL Server on Ubuntu VPS! This setup enables you to use SQL Server for development, testing, or production purposes with full command-line access.









[…] How to Install Microsoft SQL Server on Ubuntu VPS […]
[…] How to Install Microsoft SQL Server on Ubuntu VPS (10 Minute Quick-Start Guide) […]