很多人想知道ubuntu如何卸载mysql,还有些ubuntu用户总是觉得mysql卸载的不够干净,今天为大家带来的这个ubuntu卸载mysql的具体方法,就能够帮助这些用户来解决这个问题。
ubuntu卸载mysql的具体方法
我们已卸载muSQL5.7为例;
1、首先我们需要查看mysql依赖项,输入如下代码:
dpkg --list | grep mysql
以上代码输入后回车,会输出类似于如下的代码:
ii libmysqlclient-dev 5.7.34-0ubuntu0.18.04.1 amd64 MySQL database development files
ii libmysqlclient20:amd64 5.7.34-0ubuntu0.18.04.1 amd64 MySQL database client library
ii mysql-client-5.7 5.7.34-0ubuntu0.18.04.1 amd64 MySQL database client binaries
ii mysql-client-core-5.7 5.7.34-0ubuntu0.18.04.1 amd64 MySQL database core client binaries
ii mysql-common 5.8+1.0.4 all MySQL database common files, e.g. /etc/mysql/my.cnf
ii mysql-server-5.7 5.7.34-0ubuntu0.18.04.1 amd64 MySQL database server binaries and system database setup
ii mysql-server-core-5.7 5.7.34-0ubuntu0.18.04.1 amd64 MySQL database server binaries
2、然后我们就来卸载mysql-common,输入如下代码:
sudo apt remove mysql-common
以上代码输入后回车,会输出类似于如下的代码:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-6 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl
libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libtimedate-perl liburi-perl
mysql-client-core-5.7 mysql-server-core-5.7
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
libmysqlclient-dev libmysqlclient20 mysql-client-5.7 mysql-common mysql-server-5.7
0 upgraded, 0 newly installed, 5 to remove and 64 not upgraded.
After this operation, 89.0 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 110572 files and directories currently installed.)
Removing libmysqlclient-dev (5.7.34-0ubuntu0.18.04.1) ...
Removing libmysqlclient20:amd64 (5.7.34-0ubuntu0.18.04.1) ...
Removing mysql-server-5.7 (5.7.34-0ubuntu0.18.04.1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Removing mysql-client-5.7 (5.7.34-0ubuntu0.18.04.1) ...
Removing mysql-common (5.8+1.0.4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
3、接下来我们就可以卸载并清除mysql5.7,输入如下代码:
sudo apt autoremove --purge mysql-server-5.7
输入如上代码并回车,会输出类似于如下的代码:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libaio1* libcgi-fast-perl* libcgi-pm-perl* libencode-locale-perl* libevent-core-2.1-6* libfcgi-perl* libhtml-parser-perl*
libhtml-tagset-perl* libhtml-template-perl* libhttp-date-perl* libhttp-message-perl* libio-html-perl* liblwp-mediatypes-perl*
libtimedate-perl* liburi-perl* mysql-client-core-5.7* mysql-server-5.7* mysql-server-core-5.7*
0 upgraded, 0 newly installed, 18 to remove and 64 not upgraded.
After this operation, 76.3 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 110321 files and directories currently installed.)
Removing mysql-server-core-5.7 (5.7.34-0ubuntu0.18.04.1) ...
Removing mysql-client-core-5.7 (5.7.34-0ubuntu0.18.04.1) ...
Removing libaio1:amd64 (0.3.110-5ubuntu0.1) ...
Removing libcgi-fast-perl (1:2.13-1) ...
Removing libhtml-template-perl (2.97-1) ...
Removing libcgi-pm-perl (4.38-1) ...
Removing libhttp-message-perl (6.14-1) ...
Removing libencode-locale-perl (1.05-1) ...
Removing libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) ...
Removing libfcgi-perl (0.78-2build1) ...
Removing libhtml-parser-perl (3.72-3build1) ...
Removing libhtml-tagset-perl (3.20-3) ...
Removing libhttp-date-perl (6.02-1) ...
Removing libio-html-perl (1.001-1) ...
Removing liblwp-mediatypes-perl (6.02-1) ...
Removing libtimedate-perl (2.3000-2) ...
Removing liburi-perl (1.73-1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
(Reading database ... 109933 files and directories currently installed.)
Purging configuration files for mysql-server-5.7 (5.7.34-0ubuntu0.18.04.1) ...
Processing triggers for systemd (237-3ubuntu10.42) ...
Processing triggers for ureadahead (0.100.0-21) ...
4、接下来我们就要来清除残留数据,输入如下代码:
dpkg -l | grep ^rc| awk '{print$2}'| sudo xargs dpkg -P
输入如上代码并回车,会输出类似于如下的代码:
(Reading database ... 109919 files and directories currently installed.)
Purging configuration files for mysql-common (5.8+1.0.4) ...
6、接下来我们在此检查依赖项,输入如下代码:
dpkg --list | grep mysql
如果输出为空,那么表示mysql已经彻底卸载干净了,如果不为空那么我们还要继续进行删除卸载,继续输入如下代码:
sudo apt autoremove --purge mysql-apt-config
到底为止,Ubuntu上的mysql就已经彻底删除卸载干净了。