![为什么我无法重新安装 MySQL?](https://linux22.com/image/1097734/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E6%97%A0%E6%B3%95%E9%87%8D%E6%96%B0%E5%AE%89%E8%A3%85%20MySQL%EF%BC%9F.png)
- 项目清单
我一直在互联网上寻找答案,但没有找到任何东西。我希望你现在能帮助我。
我有一台装有 MySQL 的服务器。一天天过去,MySQL 不再让我使用 root 密码进入 ( accsess denied for user 'root'@'localhost' using password: 'YES'
)。因此,我尝试了两种方法来重置密码:
1号:我输入了:
shell> /etc/init.d/mysqld stop
停止 MySQL。然后我跳过授权表重新启动它:
shell> mysqld_safe --skip-grant-tables
因此我可以以 root 身份登录并使用以下命令更改密码:
mysql> UPDATE mysql.user SET Password = PASSWORD('MyNewPassword') WHERE User = 'root';
FLUSH PRIVILEGES;
我重新启动了 MySQL,并尝试使用新密码以 root 身份登录 - 但没有成功。因此我尝试了此处描述的解决方案:http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html(我不想在这里发布它,因为这篇文章已经很长了)。也没有用。实际上,这让情况变得更糟,因为从那天起,每次我尝试启动 MySQL,它甚至都不会要求我输入密码,但我得到了:
shell> ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
好吧,我查了一下它的含义,发现mysqld.sock
缺少我的。我尝试使用创建它,touch
但 MySQL 无法使用该套接字启动。
现在我试图重新安装 MySQL,但每次我输入
shell> apt-get --purge remove mysql-server mysql-common mysql-client
按照这个顺序或任何其他顺序,或者单独按照这三个顺序,我得到:
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).
所以我对自己说“让我们也删除那些具有依赖关系的文件”(因为 plesk 是虚拟的并且无法卸载,所以删除 psa 文件)...猜猜发生了什么:
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).
当然我尝试过apt-get -f install
,甚至尝试过很多次。
我做错了什么?无论我将哪些其他软件包包含进去apt-get --purge remove
,我总是会得到新的依赖项。我是否必须手动删除每个与 MySQL 相关的目录和文件?希望有人能帮助我!
干杯!
编辑:
尝试 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).
所以我尝试删除所有这些并得到:
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).
SI 也尝试删除最后一个文件,并且期待着我的问题得到解决 - 但我得到了这个:
(Reading database ... 73213 files and directories currently installed.)
Removing psa-imp ...
dpkg action:
Trying to start service mysql... /usr/sbin/mysqld (pid 14824) is running...
done
Trying to establish test connection... ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
我多次看到最后那一行。之后是这样的:
failed
ERROR while trying to establish test connection
Check the error reason(see log file: /tmp/plesk_11.0.9_installation.log), fix and try again
dpkg action:
Trying to start service mysql... /usr/sbin/mysqld (pid 14824) is running...
done
Trying to establish test connection... ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
当然,我最喜欢的台词又出现了,最后一句就是
E: Sub-process /usr/bin/dpkg returned an error code (1)
有任何想法吗?