3

I want to completely remove and re-install mysql on Ubuntu 11.10. I've tried removing it by running:

apt-get remove --purge 'mysql-.*'

But when I re-install it, the old databases are still there, so it obviously wasn't completely removes. How do I remove:

  • the server
  • databases
  • configuration files
Dónal
  • 281
  • 6
  • 12
  • removing packages won't remove your databases, you will need to delete them manually. You can find database files in /var/lib/mysql – Dmitry Alexeyev Mar 14 '12 at 19:53
  • @DmitryAlexeyev, I beg to differ the purge code in `/var/lib/dpkg/info/mysql-server-5.1.postrm` clearly has a block of code in place that should be removing `/var/lib/mysql` if the purge executed properly. – Zoredache Mar 14 '12 at 19:59
  • 1
    @Zoredache You are correct; however, the logic in that script is bad. It only removes (with prompting) `/var/lib/mysql` if `/usr/sbin/mysqld` if it isn't executable. Alas, that file is provided by mysql-server-core-5.1. Because mysql-server-5.1 depends on mysql-server-core-5.1, during a removal mysql-server-5.1 is removed first; thus `/usr/sbin/mysqld` will still exist and the data directory won't be removed. (Verified by running `dpkg --force-depends --purge mysql-server-core-5.1` and then `dkg --force-depends --purge mysql-server-5.1`. N.B. this is not a solution to the question.) – Mark Wagner Mar 14 '12 at 23:02

1 Answers1

3

Delete the default MySQL data directory is /var/lib/mysql. And finally delete the configuration directory that resides in /etc/mysql.

Reinstall and you should be good to go!

Shyam Sundar C S
  • 1,063
  • 8
  • 12