MySQL 服务器无法启动 Ubuntu 20.04.3

MySQL 服务器无法启动 Ubuntu 20.04.3

我一直尝试在我的 ubuntu 服务器上安装 mysql-server,但是当我输入以下内容时,它只给我这个错误:

mysql

这是我得到的:

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

如果我使用以下命令检查它是否打开:

sudo systemctl status mysql

我得到:

    ● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2022-04-16 23:29:16 UTC; 5min ago
    Process: 474306 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited,         status=1/FAILURE)

Apr 16 23:29:16 amir-server systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILURE
Apr 16 23:29:16 amir-server systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 16 23:29:16 amir-server systemd[1]: Failed to start MySQL Community Server.
Apr 16 23:29:16 amir-server systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Apr 16 23:29:16 amir-server systemd[1]: Stopped MySQL Community Server.
Apr 16 23:29:16 amir-server systemd[1]: mysql.service: Start request repeated too quickly.
Apr 16 23:29:16 amir-server systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 16 23:29:16 amir-server systemd[1]: Failed to start MySQL Community Server.

journalctl -xe 给我:

Apr 16 23:38:54 amir-server systemd[1]: Failed to start MySQL Community Server.
-- Subject: A start job for unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mysql.service has finished with a failure.
--
-- The job identifier is 2666039 and the job result is failed.

我尝试过重新安装,但没有成功。有趣的是,mysql 服务器在我的另一台 linux 机器上运行良好,但我需要它在这台机器上运行 :(

任何帮助是极大的赞赏!

[编辑]

pgrep -l mysql

不返回任何进程

/var/log/mysql/error.log

不存在。

如果我mysqld这样做,我会得到:

mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2022-04-17T18:30:29.693043Z 0 [Warning] [MY-010101] [Server] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.
2022-04-17T18:30:29.710554Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28-0ubuntu0.20.04.3) starting as process 29346
2022-04-17T18:30:29.976620Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-04-17T18:30:30.038737Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28-0ubuntu0.20.04.3)  (Ubuntu).

我按照@NioMarvin83 的建议做了。安装时,我得到了以下信息:

MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FROZEN for help.

里面的东西如下/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

我遇到了类似的问题。经过多次尝试,最终我还是失望而归。但是,在此之前我唯一做过的事情就是使用以下命令安装 mysql-server:sudo apt-get install mysql-server 我尝试安装并重新安装、升级并升级 ubuntu,尽管我不确定这对我的 auto xloo 部件是否有帮助。

经过多次尝试和大量时间后,它帮助了我 - 我修复了“清理”与 mysql 相关的每个文件,并重新安装了 mysql-server:sudo apt-get purge mysql-server mysql-client mysql-common sudo apt-get install mysql-server

相关内容