How to Uninstall SQL Server in PostgreSQL

Galaxy Glossary

How do I completely uninstall SQL Server from Ubuntu or RedHat?

The uninstall SQLServer command removes Microsoft SQL Server packages, data files, and related configuration from a Linux machine.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why would you uninstall SQL Server?

Freeing disk space, switching to PostgreSQL, or resolving version conflicts often requires a complete SQL Server removal.

What must you back up first?

Export any user databases, configuration scripts, and encryption keys; uninstalling deletes the /var/opt/mssql data directory.

Which packages need removal?

mssql-server, mssql-tools, and the associated ODBC drivers must be purged to prevent orphaned binaries.

How do you uninstall SQL Server on Ubuntu/Debian?

Use apt commands with --purge to remove packages and configuration files in one step.

Step-by-step removal

1.Stop the service: sudo systemctl stop mssql-server
2. Purge core package: sudo apt-get remove --purge mssql-server -y
3. Purge tools: sudo apt-get remove --purge mssql-tools unixodbc-dev -y
4. Auto-clean: sudo apt-get autoremove -y && sudo apt-get autoclean
5.Delete data dir: sudo rm -rf /var/opt/mssql

How do you verify SQL Server is gone?

Run systemctl status mssql-server; it should display “Unit mssql-server.service could not be found.”

Can you uninstall on Red Hat/CentOS similarly?

Yes—replace apt-get with yum: sudo yum remove mssql-server mssql-tools unixODBC-devel.

Best practices after uninstall

Reboot the host, update package lists, and install PostgreSQL or other services on the reclaimed ports.

Common mistakes to avoid

Skipping backups and forgetting to purge tools leave debris that break future ODBC connections.

When should you keep configuration files?

If planning a reinstall with identical settings, omit the --purge flag to preserve /etc/opt/mssql.

.

Why How to Uninstall SQL Server in PostgreSQL is important

How to Uninstall SQL Server in PostgreSQL Example Usage


# Stop service so no writes occur
echo "Stopping SQL Server" && sudo systemctl stop mssql-server
# Remove main package
sudo apt-get remove --purge mssql-server -y
# Remove command-line tools
sudo apt-get remove --purge mssql-tools unixodbc-dev -y
# Clean residual packages
sudo apt-get autoremove -y && sudo apt-get autoclean
# Delete leftover data files
sudo rm -rf /var/opt/mssql

How to Uninstall SQL Server in PostgreSQL Syntax


sudo systemctl stop mssql-server
sudo apt-get remove --purge mssql-server [-y]
sudo apt-get remove --purge mssql-tools unixodbc-dev [-y]
sudo apt-get autoremove [-y]
sudo apt-get autoclean
sudo rm -rf /var/opt/mssql

Common Mistakes

Frequently Asked Questions (FAQs)

Is it safe to delete /var/opt/mssql?

Yes, after verified backups. The directory holds databases and logs; removing it frees disk space.

Do I need to uninstall ODBC drivers?

ODBC packages are optional, but purging them prevents version mismatches when installing PostgreSQL ODBC drivers.

Will uninstalling free port 1433 immediately?

Once the mssql-server service stops, port 1433 becomes available. Verify with sudo lsof -i :1433.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.