Not able to uninstall MySQL with apt-get

21,477

Solution 1

Assuming you need to completely remove mysql related packages and its configs, please try below;

sudo apt-get remove --purge mysql*     # will remove all relating packages and its config
sudo apt-get autoremove               
sudo apt-get autoclean

And above command will completely remove all mysql related packages.

Hope it helps!!

Solution 2

If you installed MYSql from .tar.gz file, you can't able to uninstall it through Ubuntu's native package management system (apt-get).

Find the uninstall.sh script inside the extracted directory and run it to completely remove all the files related to MYSQL.

Solution 3

The following will uninstall everything that contain mysql.

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

Then run again the following to check any remaining packages.

dpkg --get-selections | grep -v deinstall | grep "mysql"

In my case, I only see mysql-common.

Reinstall and everything should work.

Share:
21,477

Related videos on Youtube

faizal
Author by

faizal

Updated on September 18, 2022

Comments

  • faizal
    faizal over 1 year

    I had downloaded the generic Linux 64 bit MySQL 5.6.17 TAR archive from http://dev.mysql.com/downloads/mysql/ and installed on my 64 bit Ubuntu 14.04, following the instructions at http://dev.mysql.com/doc/refman/5.6/en/binary-installation.html.

    I am having some problems with the server, so i want to uninstall and do a fresh installation. But if i try the usual apt-get remove mysql-server(as per How do I uninstall Mysql?), i get :

    Package 'mysql-server' is not installed, so not removed
    

    I am guessing this is because i did not use apt-get to install in the first place. I had used scripts/mysql_install_db as per the instructions.

    So is there some other way to uninstall MySQL server or is it ok to just delete the installation folder?

    Edit

    $ dpkg --get-selections | grep -v deinstall | grep "mysql"
    

    gives the below result :

    libdbd-mysql-perl               install
    libmysqlclient18:amd64          install
    mysql-client                    install
    mysql-client-5.5                install
    mysql-client-core-5.5           install
    mysql-common                    install
    mysql-workbench-community       install
    
    • AzkerM
      AzkerM almost 10 years
      Hi! I'm not too sure whether this will help but can you please try, dpkg --get-selections | grep -v deinstall | grep "mysql" and post the output if you see any packages or matches. This command will output packages relating to the word mysql while printing all the installed packages. :)
    • Avinash Raj
      Avinash Raj almost 10 years
      sudo apt-get remove mysql*
    • AzkerM
      AzkerM almost 10 years
      AvinashRaj Exactly the same command that I was trying to comment on. @faizal please look into my answer
  • faizal
    faizal almost 10 years
    Does such a script exist? I could not find it in my installation folder(find $MYSQL_HOME -name 'uninstall.sh')
  • Avinash Raj
    Avinash Raj almost 10 years
    Most of the .tar.gz files comes with an un-installation script. I don't know about MYSQL.
  • faizal
    faizal almost 10 years
    Thanks AzkerM. But i am really nervous about doing this now. I have managed to make the existing MySQL work for now after a lot of experimenting. If i do face more problems, i will surely give this a try.
  • AzkerM
    AzkerM almost 10 years
    It is always a best practice to make a use of official repo's available within Ubuntu unless you've no other choice. Anyhow, its your call & in any event we're always happy to help. :)
  • faizal
    faizal almost 10 years
    I did not use the Ubuntu repo because it was downloading MySQL 5.5, while 5.6 was available for download from the mysql site. I have realized now that was an error of judgement :(
  • AzkerM
    AzkerM almost 10 years
    Well there is a PPA for MySQL 5.6 given with an explanation on Launchpad which you should have tried. I also see certain bugs reported relating to this. Anyhow, there is no victory without pain. If your package is working and issues sorted, good to go though.
  • ipcjs
    ipcjs about 7 years
    you right. The script is /root/oneinstack/uninstall.sh on my server.
  • Claus
    Claus about 7 years
    Superb. Works like charm.
  • Lajos Mészáros
    Lajos Mészáros over 2 years
    A little side note is that I had to go to / to execute the remove --purge command. Standing in my home directory resulted in apt-get not being able to locate packages