21

I need to completely delete everything about MySQL. It was not starting so I decided to delete it. However during installation this happened:

sta@daPC:~$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libdbd-mysql-perl libmysqlclient18 mysql-client-5.6 mysql-common
  mysql-server-5.6
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  libdbd-mysql-perl libmysqlclient18 mysql-client-5.6 mysql-common
  mysql-server mysql-server-5.6
0 upgraded, 6 newly installed, 0 to remove and 87 not upgraded.
Need to get 0 B/12,0 MB of archives.
After this operation, 101 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 188526 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.6.28-0ubuntu0.15.10.1_all.deb ...
Unpacking mysql-common (5.6.28-0ubuntu0.15.10.1) ...
Selecting previously unselected package libmysqlclient18:i386.
Preparing to unpack .../libmysqlclient18_5.6.28-0ubuntu0.15.10.1_i386.deb ...
Unpacking libmysqlclient18:i386 (5.6.28-0ubuntu0.15.10.1) ...
Selecting previously unselected package libdbd-mysql-perl.
Preparing to unpack .../libdbd-mysql-perl_4.028-2_i386.deb ...
Unpacking libdbd-mysql-perl (4.028-2) ...
Selecting previously unselected package mysql-client-5.6.
Preparing to unpack .../mysql-client-5.6_5.6.28-0ubuntu0.15.10.1_i386.deb ...
Unpacking mysql-client-5.6 (5.6.28-0ubuntu0.15.10.1) ...
Processing triggers for man-db (2.7.4-1) ...
Setting up mysql-common (5.6.28-0ubuntu0.15.10.1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.6.
(Reading database ... 188621 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.6_5.6.28-0ubuntu0.15.10.1_i386.deb ...
Unpacking mysql-server-5.6 (5.6.28-0ubuntu0.15.10.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.6.28-0ubuntu0.15.10.1_all.deb ...
Unpacking mysql-server (5.6.28-0ubuntu0.15.10.1) ...
Processing triggers for man-db (2.7.4-1) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
Processing triggers for systemd (225-1ubuntu9) ...
Setting up libmysqlclient18:i386 (5.6.28-0ubuntu0.15.10.1) ...
Setting up libdbd-mysql-perl (4.028-2) ...
Setting up mysql-client-5.6 (5.6.28-0ubuntu0.15.10.1) ...
Setting up mysql-server-5.6 (5.6.28-0ubuntu0.15.10.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
2016-02-17 04:13:48 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-17 04:13:48 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28-0ubuntu0.15.10.1) starting as process 13491 ...

As you can see it is stuck on starting the MySQL server again. How can I delete MySQL completely for a fresh install?

EDIT: Problem solved itself after restarting the computer. Since I couldn't detect neither the problem nor the actual solution I am not posting it as an answer.

3 Answers 3

36

I found a solution at: https://stackoverflow.com/questions/25244606/completely-remove-mysql-ubuntu-14-04-lts/28113482#28113482

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

During the reinstallation I was prompted for a (new) password. During the unsuccessful prior reinstallation I let it empty, and mysql kept the old forgotten password of the previous installation, which I thought was empty.

2
  • 1
    This just made me completely unable to run mysql (mysql results in ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2))
    – xjcl
    Jun 3, 2020 at 11:54
  • 1
    Had to sudo rm -rf /var/lib/mysql because your command got me stuck with an incomplete config
    – xjcl
    Jun 3, 2020 at 22:01
0

dpkg -P package should purge the package entirely including configuration files. Following is the description of the option from man dpkg command

-r, --remove, -P, --purge package...|-a|--pending Remove an installed package. -r or --remove remove everything except conffiles. This may avoid having to reconfigure the pack age if it is reinstalled later. (Conffiles are configuration files that are listed in the DEBIAN/conffiles control file). -P or --purge removes everything, including conffiles. If -a or --pending is given instead of a package name, then all packages unpacked, but marked to be removed or purged in file /var/lib/dpkg/status, are removed or purged, respectively. Note: some configuration files might be unknown to dpkg because they are created and handled separately through the configuration scripts. In that case, dpkg won't remove them by itself, but the package's postrm script (which is called by dpkg), has to take care of their removal during purge. Of course, this only applies to files in system directories, not configuration files written to individual users' home directories.

0

You have to use purge:

   remove
       remove is identical to install except that packages are removed
       instead of installed. Note the removing a package leaves its
       configuration files in system. If a plus sign is appended to the
       package name (with no intervening space), the identified package
       will be installed instead of removed.

   purge
       purge is identical to remove except that packages are removed and
       purged (any configuration files are deleted too).

   --purge
       Use purge instead of remove for anything that would be removed. An
       asterisk ("*") will be displayed next to packages which are
       scheduled to be purged.  remove --purge is equivalent for purge
       command. Configuration Item: APT::Get::Purge.

Syntax:

 sudo apt-get remove --purge <package-name>

Or its equivalent:

 sudo apt-get purge <package-name>

Hope it helps.

2
  • 1
    Tried. Still same.
    – SarpSTA
    Feb 17, 2016 at 2:41
  • Did you check what process running 3309
    – Raja G
    Feb 17, 2016 at 2:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .