Completely Remove MySQL Ubuntu 14.04 LTS

Warsum picture Warsum · Aug 11, 2014 · Viewed 128k times · Source

I somehow have messed up my MySQL on my Ubuntu server and cannot fix it. I have tried every single combination of apt-get remove --purge mysql-server, apt-get autoremove, apt-get purge, Googled for hours and nothing.

I have literally given up. Every time I try to reinstall I get error. I've had enough. I want to remove every single file associated with MySQL on my server.

I get this error every time I try to reinstall which seems to be common but not one "fix" has worked for me. I need to clean my system of everything MySQL.

Unable to set password for the MySQL "root" user                                                                                                        
An error occurred while setting the password for the MySQL administrative user. This may have happened because the account already has a password, or   
because of a communication problem with the MySQL server.                                                                                               
You should check the account's password after the package installation.                                                                                 
Please read the /usr/share/doc/mysql-server-5.5/README.Debian file for more information.

Please can someone give me a set of command to purge this ungodly database from my system before I do a fresh install of the server.

Setting up mysql-server-5.5 (5.5.38-0ubuntu0.14.04.1) ...
140811 10:56:44 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.

dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.  
Processing triggers for libc-bin (2.19-0ubuntu6.1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
mysql-server-5.5
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have literally tried everything. Every single mysql file is removed and it still will not install properly.

Answer

Redaa picture Redaa · Aug 11, 2014

To Completly remove Mysql from Ubuntu :

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

after this, if you are having issues with re installing, Try to remove Mysql files in :

sudo rm -rf /var/lib/mysql

Hope this helps .