套接字不存在;无法通过套接字“/var/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器 (2)

套接字不存在;无法通过套接字“/var/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器 (2)

我知道这个问题并不新鲜。但我已经尝试了很多方法。我无法弄清楚的是,自从我下载了 mysql 后,套接字就不可用了。

/etc/my.cnf
/etc/mysql/my.cnf
/var/lib/mysql/my.cnf

以上都不是文件可用。我最初下载了 mysql-server。由于它不起作用,我下载了 MariaDB。仍然不起作用。我可以用 MySql 做的是enablerestart(但不能启动)和version check。我找不到其他可以做的事情。

尝试了以下所有链接及更多链接。123

$-mysql -u root -p -h 127.0.0.1
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (111)

如果我执行,我会收到以下消息systemctl status mysql

mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2022-10-25 20:28:52 +06; 12min ago
    Process: 23398 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
        CPU: 4ms

অক্টোবর 25 20:28:52 istiak-PASSION-BX-PRO systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
অক্টোবর 25 20:28:52 istiak-PASSION-BX-PRO systemd[1]: Stopped MySQL Community Server.
অক্টোবর 25 20:28:52 istiak-PASSION-BX-PRO systemd[1]: mysql.service: Start request repeated too quickly.
অক্টোবর 25 20:28:52 istiak-PASSION-BX-PRO systemd[1]: mysql.service: Failed with result 'exit-code'.
অক্টোবর 25 20:28:52 istiak-PASSION-BX-PRO systemd[1]: Failed to start MySQL Community Server.

我尝试重新安装,mysql-server问题仍然存在。仅供参考,我也使用 lampp-server 安装了它们,但我也找不到 lampp 文件夹/文件。

/etc/mysql$ ls
mariadb.conf.d  mysql.conf.d

mariadb.conf.d50-client.cnf.dpkg-new 50-mysql-clients.cnf.dpkg-new 60-galera.cnf.dpkg-newmysql.conf.d为空。

$ locate mysql.cnf
/etc/mysql/mysql.cnf
/etc/mysql/mysql.conf.d/mysql.cnf

/etc/mysql/mysql.conf.d$ cat mysql.cnf
cat: mysql.cnf: No such file or directory
$ cat /var/log/mysql/error.log
2022-10-25T07:48:52.228831Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.31-0ubuntu0.22.04.1) initializing of server in progress as process 28839
2022-10-25T07:48:52.302162Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-25T07:49:09.874747Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-25T07:50:06.236820Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2022-10-25T07:51:08.281884Z 6 [System] [MY-013172] [Server] Received SHUTDOWN from user boot. Shutting down mysqld (Version: 8.0.31-0ubuntu0.22.04.1).
2022-10-25T07:51:38.826105Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31-0ubuntu0.22.04.1) starting as process 28898
2022-10-25T07:51:39.554318Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-25T07:51:41.855856Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-25T07:51:46.281301Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-10-25T07:51:46.281340Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-10-25T07:51:46.333725Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory.
2022-10-25T07:51:46.379072Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2022-10-25T07:51:46.379082Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.31-0ubuntu0.22.04.1'  socket: '/tmp/tmp.AGSySmwCxw/mysqld.sock'  port: 0  (Ubuntu).
2022-10-25T07:51:46.647513Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.31-0ubuntu0.22.04.1).
2022-10-25T07:51:51.615872Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31-0ubuntu0.22.04.1)  (Ubuntu).
2022-10-25T07:51:52.202270Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31-0ubuntu0.22.04.1) starting as process 28983
2022-10-25T07:51:52.209027Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-25T07:51:54.558257Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-25T07:51:57.829629Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-10-25T07:51:57.829657Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-10-25T07:51:57.889261Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory.
2022-10-25T07:51:58.081569Z 7 [System] [MY-013172] [Server] Received SHUTDOWN from user boot. Shutting down mysqld (Version: 8.0.31-0ubuntu0.22.04.1).
2022-10-25T07:51:58.085366Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2022-10-25T07:52:01.902843Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31-0ubuntu0.22.04.1)  (Ubuntu).
2022-10-25T07:52:03.914295Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31-0ubuntu0.22.04.1) starting as process 29105
2022-10-25T07:52:04.447669Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-25T07:52:06.721404Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-25T07:52:10.519027Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-10-25T07:52:10.519055Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-10-25T07:52:10.536998Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2022-10-25T07:52:10.537077Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.31-0ubuntu0.22.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu).
2022-10-25T08:14:19.130322Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31-0ubuntu0.22.04.1) starting as process 1057
2022-10-25T08:14:20.074090Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-25T08:14:33.814659Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-25T08:14:37.852644Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
2022-10-25T08:14:37.862734Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
2022-10-25T08:14:38.881437Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-10-25T08:14:38.881467Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-10-25T08:14:39.184636Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2022-10-25T08:14:39.184667Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.31-0ubuntu0.22.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu).
2022-10-25T08:27:57.845047Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.31-0ubuntu0.22.04.1).
2022-10-25T08:27:59.876899Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31-0ubuntu0.22.04.1)  (Ubuntu).

答案1

经过比平时更长的思考,我意识到我的系统中的 MySQL 已经完全损坏。即使在删除 MySQL 时,总会留下一些文件。所以我直接再次安装了新的发行版。再次从官方页面下载了 Xampp。

$cd Downloads
$sudo chmod +x xampp.run
$sudo ./xampp.run

然后出现一个对话框(安装),安装完成后,我在 /opt 中得到了一个 Lampp 文件夹。还有一个 lampp 可执行文件 /opt/lampp/lampp

cd /opt/lampp
sudo ./lampp start

如果 lampp 不可执行则运行

sudo chmod +x lampp 

相关内容