错误 2002 (HY000):无法通过套接字“/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器 (2)

错误 2002 (HY000):无法通过套接字“/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器 (2)

你好,我这里有一个大问题,几天前服务器磁盘空间已满,然后所有服务都关闭了,我设法清理了一些空间,有 48GB 的​​可用空间,但是我现在面临的问题是无法启动 Apache、MariaDB 和 nginx 服务

每次我启动 Apache、MariaDB 或 nginx 时,它都会关闭,并且我会在电子邮件中收到一条错误:

无法连接到 MySQL 本地主机错误 2002 (HY000):无法通过套接字“/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器 (2)

service mysql restart
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
root/home/admin# systemctl status mysql.service
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset>
     Active: failed (Result: exit-code) since Fri 2023-07-21 23:47:07 CEST; 1mi>
    Process: 5983 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=e>

Jul 21 23:47:07 systemd[1]: mysql.service: Scheduled restart job, r>
Jul 21 23:47:07 systemd[1]: Stopped MySQL Community Server.
Jul 21 23:47:07 systemd[1]: mysql.service: Start request repeated t>
Jul 21 23:47:07 systemd[1]: mysql.service: Failed with result 'exit>
Jul 21 23:47:07 systemd[1]: Failed to start MySQL Community Server.

然后我尝试

systemctl status mariadb.service

Warning: The unit file, source configuration file or drop-ins of mariadb.servic>
● mariadb.service
     Loaded: masked (Reason: Unit mariadb.service is masked.)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─migrated-from-my.cnf-settings.conf
     Active: inactive (dead) since Fri 2023-07-21 23:42:42 CEST; 26min ago
   Main PID: 826 (code=exited, status=0/SUCCESS)
     Status: "MariaDB server is down"

Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] /usr/sb>
Jul 21 23:42:42 systemd[1]: mariadb.service: Succeeded.
Jul 21 23:42:42 systemd[1]: Stopped MariaDB 10.5.21 database server.
lines 1-19/19 (END)...skipping...
Warning: The unit file, source configuration file or drop-ins of mariadb.servic>
● mariadb.service
     Loaded: masked (Reason: Unit mariadb.service is masked.)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─migrated-from-my.cnf-settings.conf
     Active: inactive (dead) since Fri 2023-07-21 23:42:42 CEST; 26min ago
   Main PID: 826 (code=exited, status=0/SUCCESS)
     Status: "MariaDB server is down"

Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] InnoDB:>
Jul 21 23:42:42 mariadbd[826]: 2023-07-21 23:42:42 0 [Note] /usr/sb>
Jul 21 23:42:42 systemd[1]: mariadb.service: Succeeded.
Jul 21 23:42:42 systemd[1]: Stopped MariaDB 10.5.21 database server.

nginx:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/var/log/apache2/domains/domain.com.error.log" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed

我现在检查了空间

root: df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 383M 892K 382M 1% /run
/dev/sda1 75G 25G 48G 34% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda15 61M 2.7M 58M 5% /boot/efi
tmpfs 383M 0 383M 0% /run/user/1000

也检查了内存

root# free -h
total used free shared buff/cache available
Mem: 3.7Gi 294Mi 2.5Gi 11Mi 979Mi 3.2Gi
Swap: 0B 0B 0B

我也试过

sudo tail -f /var/log/apache2/error.log
[Sat Jul 22 00:28:29.156692 2023] [mpm_event:notice] [pid 2027:tid 1396530985873 92] AH00492: caught SIGWINCH, shutting down gracefully
[Sat Jul 22 00:29:26.864621 2023] [mpm_event:notice] [pid 4398:tid 1398630996472 32] AH00489: Apache/2.4.57 (Ubuntu) configured – resuming normal operations
[Sat Jul 22 00:29:26.864729 2023] [core:notice] [pid 4398:tid 139863099647232] A H00094: Command line: ‘/usr/sbin/apache2’
[Sat Jul 22 00:29:27.069516 2023] [mpm_event:notice] [pid 4398:tid 1398630996472 32] AH00492: caught SIGWINCH, shutting down gracefully
[Sat Jul 22 00:29:33.810002 2023] [mpm_event:notice] [pid 4946:tid 1401744768053 76] AH00489: Apache/2.4.57 (Ubuntu) configured – resuming normal operations
[Sat Jul 22 00:29:33.810084 2023] [core:notice] [pid 4946:tid 140174476805376] A H00094: Command line: ‘/usr/sbin/apache2’
[Sat Jul 22 00:29:34.229990 2023] [mpm_event:notice] [pid 4946:tid 1401744768053 76] AH00492: caught SIGWINCH, shutting down gracefully
[Sat Jul 22 00:42:05.642805 2023] [mpm_event:notice] [pid 10850:tid 140220855149 824] AH00489: Apache/2.4.57 (Ubuntu) configured – resuming normal operations
[Sat Jul 22 00:42:05.642900 2023] [core:notice] [pid 10850:tid 140220855149824] AH00094: Command line: ‘/usr/sbin/apache2’
[Sat Jul 22 00:42:06.527493 2023] [mpm_event:notice] [pid 10850:tid 140220855149 824] AH00492: caught SIGWINCH, shutting down gracefully

有什么办法可以解决这个问题吗?提前谢谢

答案1

您以某种方式设法同时安装了 MariaDB 和 MySQL。

查看以下错误:

journalctl -u mysql.service -n 80

和;

journalctl -u mariadb.service -n 80

似乎基于问题中的有限日志,MySQL 和 MariaDB 都无法根据日志错误充分识别数据以启动。

您需要将数据恢复为 MySQL 或 MariaDB 可以理解的格式。如果没有两者的日志,我无法说明如何做到这一点。请将信息编辑journalctl到您的问题中。

相关内容