The uninstall SQLServer command removes Microsoft SQL Server packages, data files, and related configuration from a Linux machine.
Freeing disk space, switching to PostgreSQL, or resolving version conflicts often requires a complete SQL Server removal.
Export any user databases, configuration scripts, and encryption keys; uninstalling deletes the /var/opt/mssql data directory.
mssql-server, mssql-tools, and the associated ODBC drivers must be purged to prevent orphaned binaries.
Use apt commands with --purge to remove packages and configuration files in one step.
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
Run systemctl status mssql-server; it should display “Unit mssql-server.service could not be found.”
Yes—replace apt-get with yum: sudo yum remove mssql-server mssql-tools unixODBC-devel.
Reboot the host, update package lists, and install PostgreSQL or other services on the reclaimed ports.
Skipping backups and forgetting to purge tools leave debris that break future ODBC connections.
If planning a reinstall with identical settings, omit the --purge flag to preserve /etc/opt/mssql.
.
Yes, after verified backups. The directory holds databases and logs; removing it frees disk space.
ODBC packages are optional, but purging them prevents version mismatches when installing PostgreSQL ODBC drivers.
Once the mssql-server service stops, port 1433 becomes available. Verify with sudo lsof -i :1433.