无法启动 mysql 服务:单元 mysql.service 被屏蔽

无法启动 mysql 服务:单元 mysql.service 被屏蔽

我正在尝试安装 phpMyAdmin,它抱怨无法连接到 MySQL 服务器。似乎相关服务未启动,但我无法启动它。

这是我运行的一些命令的结果。

# mysql -v
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
# service mysql stop
# service mysql start
Failed to start mysql.service: Unit mysql.service is masked.
# service mysqld stop
# service mysqld start
Failed to start mysqld.service: Unit mysqld.service is masked.
# systemctl unmask mysql.service
# service mysql start
Failed to start mysql.service: Unit mysql.service is masked.
# systemctl unmask mysqld.service
# service mysqld start
Failed to start mysqld.service: Unit mysqld.service is masked.

更新:

$ file /lib/systemd/system/mysql.service  
/lib/systemd/system/mysql.service: ASCII text
$ file /lib/systemd/system/mysqld.service     
/lib/systemd/system/mysqld.service: cannot open `/lib/systemd/system/mysqld.service' (No such file or directory)

更新:

我尝试删除/var/lib/mysql并重新启动 mysql,但失败了,并告诉我读取/etc/mysql/FROZEN,其中显示:

This MySQL or variant installation has entered "frozen mode". Maintainer
scripts will avoid making changes or starting the daemon until manually
released from this state. See /usr/share/doc/mysql-common/README for
general information about this mode.

In this particular case, an incompatible downgrade attempt has been
detected. This can be resolved in one of two ways:

1. Change the contents of /var/lib/mysql/ to contain database data that
is compatible with the currently installed MySQL or variant daemon
version. For example: you could restore from a backup. Alternatively you
could do a dump using a future version binary and then a restore using
the current version binary.

2. Switch to a MySQL or variant daemon version that is compatible with
the data currently in /var/lib/mysql/. For example, if you have
attempted a downgrade from mysql-server-5.7 to mysql-server-5.6, you
could "apt install mysql-server-5.7" again.

Please resolve this situation and only then remove the /etc/mysql/FROZEN
symlink. You can then run "dpkg-reconfigure <package>" where <package>
should usually be in the form <variant>-server-<version>.

这是什么意思?我从未尝试过降级。

答案1

问题解决了!

我删除了/etc/mysql然后它抱怨没有my.cnf

然后我进行了完全重新安装(清除“mysql*”并重新安装它们),并且它起作用了。

相关内容