Unable to install anything on Ubuntu Server [duplicate]

Solution 1:

You have to change the postrm to purge the package:

  1. Open the file

    sudo nano /var/lib/dpkg/info/mysql-server-5.5.postrm
    
  2. Find the code snippet

    if [ -n "`$MYADMIN ping 2>/dev/null`" ]; then
      stop_server
      sleep 2
    fi
    

    and comment the line stop_server

    if [ -n "`$MYADMIN ping 2>/dev/null`" ]; then
      # stop_server
      sleep 2
    fi
    
  3. Save the file and purge again

    sudo apt-get purge mysql-server-5.5
    

After that, you have repaired your system and you can install and uninstall packages again.