注:一起卸载亲测可行,不要用本文方法单独卸载nginx!!!!
一、卸载MySQL
1、停止mysql服务
sudo service mysql stop
2、查看自己的mysql有哪些依赖
root@hos:/opt/install_minercloud.bak# dpkg --list|grep mysql
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.34-0ubuntu0.18.04.1 all MySQL database server (metapackage depending on the latest version)
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
3、卸载mysql-common
sudo apt-get remove mysql-common
4、卸载剩余mysql服务
sudo apt-get autoremove --purge mysql-server-5.7
5、清除残留
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
6、检查是否卸载干净
dpkg --list|grep mysql
mysql -u root -p
which mysql
二、卸载Nginx
注:不建议单独卸载nginx!可能会影响mysql!而且重装也可能会失败!
1、停止Nginx服务
sudo service nginx stop
2、删除nginx(–purge包括配置文件)
sudo apt-get --purge remove nginx
3、移除全部不使用的软件包
sudo apt-get autoremove
4、列出未删的nginx相关的软件
dpkg --get-selections|grep nginx
5、删除3中列出的软件
sudo apt-get --purge remove nginx
sudo apt-get --purge remove nginx-common
sudo apt-get --purge remove nginx-core
6、检查是否卸载完成
dpkg --get-selections|grep nginx
which nginx
三、一键卸载脚本
#!/bin/bash
# uninstall mysql
service mysql stop
dpkg --list|grep mysql
sudo apt-get remove mysql-common -y
dpkg --list|grep mysql
sudo apt-get autoremove --purge mysql-server-5.7 -y
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
dpkg --list|grep mysql
mysql -u root -p
which mysql
# uninstall nginx
sudo service nginx stop
sudo apt-get --purge remove nginx -y
dpkg --get-selections|grep nginx
sudo apt-get --purge remove nginx -y
sudo apt-get --purge remove nginx-common -y
sudo apt-get --purge remove nginx-core -y
dpkg --get-selections|grep nginx
which nginx
# uninstall redis
service redis stop
apt-get --purge remove redis -y
dpkg --get-selections|grep redis
sudo apt-get --purge remove redis-server -y
sudo apt-get --purge remove redis-tools -y
dpkg --get-selections|grep redis
which redis