无法在 ubuntu 12.04.5 TLS 上删除 mysql-server

无法在 ubuntu 12.04.5 TLS 上删除 mysql-server

我正在尝试重新安装 mysql-server-5.6,但我什么也做不了,每次我都会收到这个奇怪的消息:

root@ps****:/home/nikitasorokin# apt-get remove --purge mysql-server-5.6
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  mysql-client-core-5.6
Use 'apt-get autoremove' to remove it.
The following packages will be REMOVED:
  mysql-server-5.6*
0 upgraded, 0 newly installed, 1 to remove and 941 not upgraded.
1 not fully installed or removed.
After this operation, 52.5 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 122623 files and directories currently installed.)
Removing mysql-server-5.6 (5.6.25-0ubuntu1) ...
stop: Unknown instance: 
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing package mysql-server-5.6 (--purge):
 subprocess installed pre-removal script returned error exit status 1
stop: Unknown instance: 
invoke-rc.d: initscript mysql, action "stop" failed.
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 mysql-server-5.6
E: Sub-process /usr/bin/dpkg returned an error code (1)

我知道,主要的建议是完全卸载 mysql 及其所有组件,但我做不到。请问您能考虑任何解决方案吗?

答案1

  1. 编辑post-installation脚本

    sudo nano /var/lib/dpkg/info/mysql-server-5.6.postinst
    
  2. 搜索功能

    invoke() {
        if [ -x /usr/sbin/invoke-rc.d ]; then
            invoke-rc.d mysql $1
        else
            /etc/init.d/mysql $1
        fi
    }
    

    并替换为

    invoke() {
        echo
        #if [ -x /usr/sbin/invoke-rc.d ]; then
        #     invoke-rc.d mysql $1
        #else
        #     /etc/init.d/mysql $1
        #fi
    }
    
  3. 保存文件

  4. 编辑pre-removal脚本

    sudo nano /var/lib/dpkg/info/mysql-server-5.6.prerm
    
  5. 搜索行

    if [ -x "/etc/init.d/mysql" ] || [ -e "/etc/init/mysql.conf" ]; then
            invoke-rc.d mysql stop || exit $?
    fi
    

    并替换

    if [ -x "/etc/init.d/mysql" ] || [ -e "/etc/init/mysql.conf" ]; then
            echo
            #invoke-rc.d mysql stop || exit $?
    fi
    
  6. 编辑post-removal脚本

    sudo nano /var/lib/dpkg/info/mysql-server-5.6.postrm
    
  7. 搜索

    # New packaging paradigm for my.cnf as of Dec-2014 for sharing mysql
    # variants in Ubuntu.
    case "$1" in
      remove|disappear)
        /usr/share/mysql-common/configure-symlinks remove mysql "$mysql_cfgdir/mysql.cnf"
      ;;
    esac
    

    并替换

    # New packaging paradigm for my.cnf as of Dec-2014 for sharing mysql
    # variants in Ubuntu.
    case "$1" in
      remove|disappear)
        # /usr/share/mysql-common/configure-symlinks remove mysql "$mysql_cfgdir/mysql.cnf"
      ;;
    esac
    
  8. 保存文件并再次运行命令

    sudo apt-get remove --purge mysql-server-5.6
    

相关内容