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

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

我刚刚在我的 parrot sec 上安装了 mariadb 并且我尝试了sudo mysql_secure_installation以下输出:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)

我也尝试过mysql -v ,但出现了同样的错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)

输出如下systemctl start mariadb

Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.

输出如下systemctl status mariadb.service

● mariadb.service - MariaDB 10.5.8 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Sun 2021-02-14 21:14:29 +01; 2min 13s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 212070 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 212071 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 212073 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
    Process: 212121 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
   Main PID: 212121 (code=exited, status=1/FAILURE)
     Status: "MariaDB server is down"
        CPU: 182ms

答案1

我刚刚发现这个错误是因为我没有mysql-server在我的计算机上安装,而且 parrot sec 不再支持 mysql。我确实安装了 XAMPP,并且确实使用命令在 XAMPP 上使用集成 mysql 运行了 mysql,mysql -h 127.0.0.1 -P 3306 -u root -p但您需要先运行 xampp 并在其上启动 mysql,然后一切都应该正常工作

相关内容