Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Completely Remove MySQL Ubuntu 14.04 LTS

Tags:

mysql

ubuntu

lts

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.

like image 782
Warsum Avatar asked Aug 11 '14 13:08

Warsum


People also ask

How do I Uninstall MySQL completely?

To uninstall MySQL on Windows, make sure that your first stop the running server. Once the server is stopped, you can uninstall MySQL via the Windows "Control Panel". Go to "Programs and Features" and select "MySQL" => "Uninstall".


2 Answers

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 .

like image 80
Redaa Avatar answered Sep 17 '22 13:09

Redaa


I experienced a similar issue on Ubuntu 14.04 LTS after a MySQL update.

I started getting error: "Fatal error: Can't open and lock privilege tables: Incorrect file format 'user'" in /var/log/mysql/error.log

MySQL could not start.

I resolved it by removing the following directory: /var/lib/mysql/mysql

sudo rm -rf /var/lib/mysql/mysql 

This leaves your other DB related files in place, only removing the mysql related files.

After running these:

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

Then reinstalling mysql:

sudo apt-get install mysql-server 

It worked perfectly.

like image 21
Grant Avatar answered Sep 17 '22 13:09

Grant