ubuntu 18.04 卸载 mysql 过程记录

20190418 为了测试 Docker LNMP 学习环境,卸载掉之前已经安装的 mysql

参考:
https://blog.csdn.net/iehadoop/article/details/82961264
https://www.cnblogs.com/hupeng1234/p/7003543.html

人家写的很详细了,我这里记录一下我自己的操作过程

  1. 停止 mysql 服务
    sudo service mysql status
    sudo service mysql stop

  2. 查询 mysql 依赖
    :~$ dpkg --list|grep mysql

     ii  dbconfig-mysql                        2.0.9                                      all          dbconfig-common MySQL/MariaDB support
     ii  mysql-client-5.7                      5.7.25-0ubuntu0.18.04.2                    amd64        MySQL database client binaries
     ii  mysql-client-core-5.7                 5.7.25-0ubuntu0.18.04.2                    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.25-0ubuntu0.18.04.2                    all          MySQL database server (metapackage depending on the latest version)
     ii  mysql-server-5.7                      5.7.25-0ubuntu0.18.04.2                    amd64        MySQL database server binaries and system database setup
     ii  mysql-server-core-5.7                 5.7.25-0ubuntu0.18.04.2                    amd64        MySQL database server binaries
     ii  php-mysql                             1:7.2+60ubuntu1                            all          MySQL module for PHP [default]
     ii  php7.2-mysql                          7.2.15-0ubuntu0.18.04.2                    amd64        MySQL module for PHP
    
  3. 逐个卸载
    sudo apt-get remove mysql-common
    出错了!

     The following packages have unmet dependencies:
      	dbconfig-mysql : Depends: default-mysql-client but it is not going to be installed or
                                virtual-mysql-client
     E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
    

    sudo apt-get autoremove --purge mysql-server-5.7
    sudo apt-get autoremove --purge mysql-server-core-5.7
    sudo apt-get autoremove --purge mysql-client-5.7
    sudo apt-get autoremove --purge mysql-client-core-5.7
    再来
    sudo apt-get remove mysql-common

  4. 遇到错误
    $ sudo apt-get autoremove --purge mysql-client-5.7

     Reading package lists... Done
     Building dependency tree       
     Reading state information... Done
     You might want to run 'apt --fix-broken install' to correct these.
     The following packages have unmet dependencies:
      mysql-server-5.7 : Depends: mysql-client-5.7 (>= 5.7.34-0ubuntu0.18.04.1) but it is not going to be installed
      phpmyadmin : Depends: php
                   Depends: php-cli
                   Depends: php-mysql or
                            php-mysqli
                   Depends: php-json
                   Depends: php-mbstring
                   Depends: php-xml
                   Depends: dbconfig-mysql but it is not going to be installed or
                            dbconfig-no-thanks but it is not going to be installed or
                            dbconfig-common (< 2.0.0) but it is not going to be installed
                   Depends: php-php-gettext but it is not going to be installed or
                            php-gettext (<= 1:7.0) but it is not going to be installed
                   Depends: php-phpseclib (>= 2.0)
                   Recommends: php-curl
                   Recommends: php-gd
                   Recommends: php-bz2
                   Recommends: php-zip
                   Recommends: php-tcpdf but it is not going to be installed
     E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
    

执行
$ sudo apt --fix-broken install
完成之后,再来!

  1. 清除残留

     dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
    

    sudo apt autoremove

    我这里没有什么数据,可以是除

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

    实际环境下还是小心为好!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

哈哈虎123

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值