How do I totally remove SQL Server 2017 on Ubuntu?

Posted on

Question :

The docs has instructions about how to remove SQL Server. However, this leaves certain packages behind. How can I remove all traces and uninstall SQL Server 2017?

Answer :

These are actually very poor instructions on how to remove the Microsoft SQL Server.

SQL Server installs these associated packages.


Assuming you wish to totally remove SQL Server, you should

# Stop the service
systemctl stop mssql-server.service

sudo add-apt-repository --remove "$(curl$(lsb_release -rs)/prod.list)"

# Remove those packages from the system.
sudo apt-get --purge remove mssql-server mssql-server-fts mssql-tools msodbcsql unixodbc-dev

# Delete the SQL Server repositories
sudo rm /etc/apt/sources.list.d/mssql-* /etc/apt/sources.list.d/msprod*

# Remove the Microsoft keys.
apt-key del "BC52 8686 B50D 79E3 39D3  721C EB3E 94AD BE12 29CF"

# Delete the Microsoft created directories
sudo rm -rf /var/opt/mssql/ /opt/{microsoft,mssql-tools,mssql}/ /usr/share/doc/{msodbcsql,mssql-server,mssql-tools}

Leave a Reply

Your email address will not be published. Required fields are marked *