Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed Mysql using sudo apt-get. Now I need to remove it from my system.

How can I do that?

share|improve this question
up vote 112 down vote accepted

To remove mysql completely from your system Just type in terminal

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean
share|improve this answer
1  
I guess this doesn't work. After I do these steps, I tried : sudo apt-get install mysql-client-core-5.5. But it shows : mysql-client-core-5.5 is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 97 not upgraded.. Is that mean still mysql resides in my pc? – batman Aug 6 '12 at 9:35
    
Try sudo dpkg --purge mysql-server mysql-client mysql-common – K.K Patel Aug 6 '12 at 10:46
    
If I try sudo dpkg --purge mysql-server mysql-client mysql-common I get : dpkg: warning: there's no installed package matching mysql-server dpkg: warning: there's no installed package matching mysql-client dpkg: warning: there's no installed package matching mysql-common . I'm bit confused now. Is that mysql have been removed or not? – batman Aug 6 '12 at 11:17
3  
this wasn't sufficient for me, a few more things had to be done: stackoverflow.com/a/16178696/447661 – Mihai Rotaru Jul 26 '14 at 21:07
2  
This also wasn't sufficient for me - for me, also, the answer here instead worked: stackoverflow.com/a/16178696/368896 – Dan Nissenbaum Oct 9 '15 at 8:35

all the above solutions are correct but I would try with

sudo apt-get remove --purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean

This will uninstall all mysql related packages.

share|improve this answer
3  
This is the easiest/simplest way to get rid of everything mysql-related. Though the wildcard here will match pretty much any package with 'mysq' in it's name, so you might want to specify sudo apt-get remove --purge -s 'mysql*' to be more specific. – geerlingguy May 23 '14 at 18:52
    
Seconded on the use of a more specific regex. I ended up using the regex of '^mysql-' Initially, I was going to run mysql, but found out it caught a ton of stuff unrelated...like:Note, selecting 'mysql-testsuite' for regex '^mysql*' Note, selecting 'mysql-server' for regex '^mysql*' Note, selecting 'mysql-server-core' for regex '^mysql*' Note, selecting 'mysqmail' for regex '^mysql*' Note, selecting 'mysqmail-pure-ftpd-logger' for regex '^mysql*' – MaasSql Mar 11 '15 at 16:18
    
I tried all the commands listed here and afterwards if I type 'mysql' into the terminal and press tab twice I still see some option come up for mysql, does this mean anything? > mysql mysqld mysql_upgrade mysqlcheck mysql_install_db – GoProCameraByGoPro Mar 26 '15 at 20:45
    
This only worked for me when I used sudo apt-get -f autoremove – Simon D Oct 21 '15 at 5:33

This will remove mysql 5.6 from ubuntu 15.04

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
share|improve this answer
    
Manually removing the directories seemed necessary for me (so +1), perhaps because my directories were symbolic links? – Jonathan Dec 13 '15 at 9:20

I don't use Ubuntu much but what I think you should try is what I did.

I first typed this in command line : sudo apt-get remove --purge mysql-server mysql-client mysql-common,

then followed with this below : sudo apt-get autoremove

and finally typed this : sudo apt-get autoclean.

I found that it was removed.

share|improve this answer

I forgot the mysql root password and needed to reset. I tried this http://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password and didn't work because it kept saying can't write logs or similar. Now my solution was to completely remove mysql from Ubuntu13.10 and fresh installation.

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo rm -rf /var/lib/mysql

I had to run the last commandline, because Ubuntu sometimes keeps some libs even you try purge them all. Now install mysql server and client

sudo apt-get install mysql-client mysql-server
share|improve this answer

First you need to stop your mysql server from service.

sudo service mysql stop

Then You can use purge command to uninstall

sudo apt-get purge mysql-server mysql-client

Note: the above based on your package list. I have installed both server and client. This will for your convineient

share|improve this answer

protected by Byte Commander Feb 25 at 7:53

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.