Why can't I reinstall MySQL?

Posted by Johannes Nielsen on Ask Ubuntu See other posts from Ask Ubuntu or by Johannes Nielsen
Published on 2012-12-04T20:22:39Z Indexed on 2012/12/05 17:27 UTC
Read the original article Hit count: 851

Filed under:
|
|

I've been looking all around the Internet for an answer but didn't find anything. I hope you can help me now.

I have a server with MySQL. From one day to another, MySQL didn't let me enter with my root password anymore (accsess denied for user 'root'@'localhost' using password: 'YES'). So I tried two ways to reset the password:

No.1: I typed:

    shell> /etc/init.d/mysqld stop

To stop MySQL. Then I restarted it skipping the grant-tables:

    shell> mysqld_safe --skip-grant-tables

So I was able to log in as root and change the password using:

    mysql> UPDATE mysql.user SET Password = PASSWORD('MyNewPassword') WHERE User = 'root';
    FLUSH PRIVILEGES;

I restarted MySQL and tried to log in as root with my new password - didn't work. So I tried the solution that's described here: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html (I don't want to post it here because this post is already pretty long). Didn't work either. Actually it made it worse, because since that day, every time I try to start MySQL, it doesn't even ask me for my password, but I get:

    shell> ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

Well, I've looked up what it means and found that my mysqld.sock is missing. I tried to create it using touch but MySQL can't start with that socket.

Now I'm trying to reinstall MySQL but everytime I type in

    shell> apt-get --purge remove mysql-server mysql-common mysql-client 

In that or any other order or every one of those three alone, I get:

    shell> Reading package lists... Done
    shell> Building dependency tree       
    shell> Reading state information... Done
    shell> Package mysql-client is not installed, so not removed
    shell> Package mysql-server is not installed, so not removed
    shell> You might want to run 'apt-get -f install' to correct these:
    shell> The following packages have unmet dependencies:
    shell>  libmysqlclient18 : Depends: mysql-common (>= 5.5.28-0ubuntu0.12.04.2) but it is not going to be installed
    shell>  libmysqlclient18:i386 : Depends: mysql-common:i386 (>= 5.5.28-0ubuntu0.12.04.2)
    shell>  mysql-client-5.5 : Depends: mysql-common (>= 5.5.28-0ubuntu0.12.04.2) but it is not going to be installed
    shell>  mysql-server-5.5 : PreDepends: mysql-common (>= 5.5.28-0ubuntu0.12.04.2) but it is not going to be installed
    shell>  psa-firewall : Depends: plesk-core (>= 11.0.9) but it is not installable
    shell>                 Depends: mysql-server but it is not going to be installed
    shell>  psa-spamassassin : Depends: plesk-core (>= 11.0.9) but it is not installable
    shell>  psa-vpn : Depends: plesk-core (>= 11.0.9) but it is not installable
    shell>            Depends: plesk-base (>= 11.0.9) but it is not installable
    shell>            Depends: mysql-server but it is not going to be installed
    shell> E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

So I said to my self "let's just remove those files with depenencies, too" (that psa-stuff since plesk is virtual and can't be uninstalled)... Guess what happened:

    shell> Reading package lists... Done
    shell> Building dependency tree       
    shell> Reading state information... Done
    shell> Package mysql-client is not installed, so not removed
    shell> Package mysql-server is not installed, so not removed
    shell> You might want to run 'apt-get -f install' to correct these:
    shell> The following packages have unmet dependencies:
    shell>  libmysqlclient18 : Depends: mysql-common (>= 5.5.28-0ubuntu0.12.04.2) but it is not going to be installed
    shell>  libmysqlclient18:i386 : Depends: mysql-common:i386 (>= 5.5.28-0ubuntu0.12.04.2)
    shell>  mysql-client-5.5 : Depends: mysql-common (>= 5.5.28-0ubuntu0.12.04.2) but it is not going to be installed
    shell>  mysql-server-5.5 : PreDepends: mysql-common (>= 5.5.28-0ubuntu0.12.04.2) but it is not going to be installed
    shell> E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Of course I tried apt-get -f install, too many times even.

What am I doing wrong? No matter, which other packages I include into apt-get --purge remove, I always get new dependencies. Do I have to delete every MySQL-related directory and file manually? Hope there's someone out there who can help me!

Cheers!

EDIT:

After trying apt-get purge mysql-server mysql-common mysql-client libmysqlclient18 libmysqlclient18:i386 mysql-client-5.5 mysql-server-5.5 psa-firewall psa-spamassassin psa-vpn

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Package mysql-client is not installed, so not removed
    Package mysql-server is not installed, so not removed
    You might want to run 'apt-get -f install' to correct these:
    The following packages have unmet dependencies:
     libdbd-mysql-perl : Depends: libmysqlclient18 (>= 5.5.13-1) but it is not going to be installed
     libmyodbc : Depends: libmysqlclient18 (>= 5.5.13-1) but it is not going to be installed
     libqt4-sql-mysql:i386 : Depends: libmysqlclient18:i386 (>= 5.5.13-1) but it is not going to be installed
     php5-mysql : Depends: libmysqlclient18 (>= 5.5.13-1) but it is not going to be installed
     ruby-mysql : Depends: libmysqlclient18 (>= 5.5.13-1) but it is not going to be installed
     E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

So I tried to remove all these and got:

    Building dependency tree       
    Reading state information... Done
    Package mysql-client is not installed, so not removed
    Package mysql-server is not installed, so not removed
    You might want to run 'apt-get -f install' to correct these:qlclient18:i386 mysql
    The following packages have unmet dependencies:
     libmysql-ruby1.8 : Depends: ruby-mysql but it is not going to be installed
    E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

And actually I think removing that file, too solved my problem :-S Next time I'll try everything before asking :D Thank you Eric for keeping me couraged to just go on removing :D

© Ask Ubuntu or respective owner

Related posts about installation

Related posts about uninstall