If you have messed up with installation or you do not want MySQL 8 version, you can uninstall using the following steps. Before uninstalling, make sure to make backup files (refer to Chapter 7, Backups), if required, and stop MySQL.
Uninstalling will be dealt in a different way on different systems. Let's look at how.
shell> rpm -qa | grep -i mysql-community mysql-community-libs-8.0.3-0.1.rc.el7.x86_64 mysql-community-common-8.0.3-0.1.rc.el7.x86_64 mysql-community-client-8.0.3-0.1.rc.el7.x86_64 mysql-community-libs-compat-8.0.3-0.1.rc.el7.x86_64 mysql-community-server-8.0.3-0.1.rc.el7.x86_64
- Remove the packages. You may be notified that there are other packages dependent on MySQL. If you plan on installing MySQL again, you can ignore the warning by passing the
--nodeps
option:
shell> rpm -e <package-name>
For example:
shell> sudo rpm -e mysql-community-server
- To remove all packages:
shell> sudo rpm -qa | grep -i mysql-community | xargs sudo rpm -e --nodeps warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave
shell> dpkg -l | grep -i mysql
- Remove the packages using the following:
shell> sudo apt-get remove mysql-community-server mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core -y Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core mysql-server 0 upgraded, 0 newly installed, 7 to remove and 341 not upgraded. After this operation, 357 MB disk space will be freed. (Reading database ... 134358 files and directories currently installed.) Removing mysql-server (8.0.3-rc-1ubuntu16.04) ... Removing mysql-community-server (8.0.3-rc-1ubuntu16.04) ... update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode Removing mysql-client (8.0.3-rc-1ubuntu16.04) ... Removing mysql-community-client (8.0.3-rc-1ubuntu16.04) ... Removing mysql-common (8.0.3-rc-1ubuntu16.04) ... Removing mysql-community-client-core (8.0.3-rc-1ubuntu16.04) ... Removing mysql-community-server-core (8.0.3-rc-1ubuntu16.04) ... Processing triggers for man-db (2.7.5-1) ...
Or remove them using:
shell> sudo apt-get remove --purge mysql-\* -y shell> sudo apt-get autoremove -y
- Verify that the packages are uninstalled:
shell> dpkg -l | grep -i mysql
ii mysql-apt-config 0.8.9-1 all Auto configuration for MySQL APT Repo.
rc mysql-common 8.0.3-rc-1ubuntu16.04 amd64 MySQL Common
rc mysql-community-client 8.0.3-rc-1ubuntu16.04 amd64 MySQL Client
rc mysql-community-server 8.0.3-rc-1ubuntu16.04 amd64 MySQL Server
rc
indicates that the packages have been removed (r
), and only config files (c
) have been kept.
It is very simple to uninstall a binary installation. All you need to do is to remove the symlink:
- Change the directory to the installation path:
shell> cd /usr/local
- Check where
mysql
is pointing to, which will show the path it is referencing to:
shell> sudo ls -lh mysql
- Remove
mysql
:
shell> sudo rm mysql
- Remove the binaries (optional):
shell> sudo rm -f /opt/mysql-8.0.3-rc-linux-glibc2.12-x86_64.tar.gz