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

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

主要目的

ubuntu server 20.04我正在尝试在我的以下设备上安装本地版本的 Prestashop脚步

问题

我目前正在尝试安装 MariaDB(指南的第 5 步),尝试运行命令后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
you haven't set the root password yet, the password will be blank,
so 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 '/var/run/mysqld/mysqld.sock' (2)

我尝试过

我尝试四处查看并检查我的套接字,sudo find / -type s结果发现没有任何/var/lib/mysql文件夹。

输出sudo find / -type s

/var/lib/samba/private/msg.sock/995
/var/lib/samba/private/msg.sock/1018
/var/lib/samba/private/msg.sock/1140
/var/lib/samba/private/msg.sock/978
/var/lib/samba/private/msg.sock/774
/var/lib/samba/private/msg.sock/1173
/var/lib/samba/private/msg.sock/1002
/var/lib/samba/private/msg.sock/954
/var/lib/samba/private/msg.sock/1139
/var/lib/samba/private/msg.sock/1211
/var/lib/samba/private/msg.sock/1312
/var/lib/samba/private/msg.sock/1186
/var/lib/samba/private/msg.sock/959
/var/lib/samba/private/msg.sock/937
/var/lib/samba/private/msg.sock/1161
/var/lib/samba/private/msg.sock/1225
/var/lib/samba/private/msg.sock/1009
/var/lib/samba/private/msg.sock/1160
/var/lib/samba/private/msg.sock/19992
/var/lib/samba/private/msg.sock/19790
/var/lib/samba/private/msg.sock/1322
/var/lib/samba/private/msg.sock/1254
/var/lib/samba/private/msg.sock/19755
/var/lib/samba/private/msg.sock/19789
/var/lib/samba/private/msg.sock/20005
/var/lib/samba/private/msg.sock/770
/var/lib/samba/private/msg.sock/26712
/var/lib/samba/private/msg.sock/702
/var/lib/samba/private/msg.sock/1227
/var/lib/samba/private/msg.sock/1200
/var/lib/samba/private/msg.sock/1291
/var/lib/samba/winbindd_privileged/pipe
/var/spool/postfix/private/local
/var/spool/postfix/private/proxymap
/var/spool/postfix/private/trace
/var/spool/postfix/private/error
/var/spool/postfix/private/lmtp
/var/spool/postfix/private/relay
/var/spool/postfix/private/anvil
/var/spool/postfix/private/maildrop
/var/spool/postfix/private/verify
/var/spool/postfix/private/mailman
/var/spool/postfix/private/bounce
/var/spool/postfix/private/smtp
/var/spool/postfix/private/defer
/var/spool/postfix/private/virtual
/var/spool/postfix/private/discard
/var/spool/postfix/private/bsmtp
/var/spool/postfix/private/tlsmgr
/var/spool/postfix/private/rewrite
/var/spool/postfix/private/ifmail
/var/spool/postfix/private/proxywrite
/var/spool/postfix/private/retry
/var/spool/postfix/private/scache
/var/spool/postfix/private/scalemail-backend
/var/spool/postfix/private/uucp
/var/spool/postfix/public/postlog
/var/spool/postfix/public/showq
/var/spool/postfix/public/cleanup
/var/spool/postfix/public/flush
/var/spool/postfix/public/qmgr
/var/spool/postfix/public/pickup
/var/spool/postfix/dev/log
/var/snap/lxd/common/lxd/unix.socket
/run/php/php7.2-fpm.sock
/run/dovecot/master
/run/dovecot/anvil-auth-penalty
/run/dovecot/anvil
/run/dovecot/auth-worker
/run/dovecot/auth-master
/run/dovecot/auth-userdb
/run/dovecot/auth-client
/run/dovecot/auth-login
/run/dovecot/config
/run/dovecot/dict-async
/run/dovecot/dict
/run/dovecot/director-userdb
/run/dovecot/director-admin
/run/dovecot/dns-client
/run/dovecot/doveadm-server
/run/dovecot/imap-hibernate
/run/dovecot/imap-urlauth
/run/dovecot/imap-urlauth-worker
/run/dovecot/imap-master
/run/dovecot/indexer
/run/dovecot/indexer-worker
/run/dovecot/ipc
/run/dovecot/log-errors
/run/dovecot/old-stats
/run/dovecot/replication-notify
/run/dovecot/replicator
/run/dovecot/stats-writer
/run/dovecot/stats-reader
/run/dovecot/token-login/tokenlogin
/run/dovecot/token-login/imap-urlauth
/run/dovecot/login/login
/run/dovecot/login/imap
/run/dovecot/login/ipc-proxy
/run/dovecot/login/pop3
/run/irqbalance/irqbalance767.sock
/run/uuidd/request
/run/snapd-snap.socket
/run/snapd.socket
/run/dbus/system_bus_socket
/run/user/1000/snapd-session-agent.socket
/run/user/1000/pk-debconf-socket
/run/user/1000/gnupg/S.gpg-agent
/run/user/1000/gnupg/S.gpg-agent.ssh
/run/user/1000/gnupg/S.gpg-agent.extra
/run/user/1000/gnupg/S.gpg-agent.browser
/run/user/1000/gnupg/S.dirmngr
/run/user/1000/bus
/run/user/1000/systemd/private
/run/user/1000/systemd/notify
/run/user/1000/inaccessible/sock
/run/samba/winbindd/pipe
/run/samba/nmbd/unexpected
/run/postgresql/.s.PGSQL.5432
/run/lvm/lvmpolld.socket
/run/systemd/journal/io.systemd.journal
/run/systemd/journal/socket
/run/systemd/journal/stdout
/run/systemd/journal/dev-log
/run/systemd/journal/syslog
/run/systemd/userdb/io.systemd.DynamicUser
/run/systemd/private
/run/systemd/notify
/run/systemd/inaccessible/sock
/run/udev/control

编辑

  1. 我尝试了一下mkdir /var/lib/mysql,但奇怪的是输出是:
mkdir: cannot create directory ‘/var/lib/mysql’: File exists
  1. 我尝试启动 MariaDB,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.3.22 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor pres>
     Active: failed (Result: exit-code) since Sun 2020-05-10 12:19:19 UTC; 11s >
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 38200 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /va>
    Process: 38206 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_S>
    Process: 38215 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] &&>
    Process: 38264 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER >
   Main PID: 38264 (code=exited, status=1/FAILURE)

May 10 12:19:18 chale-server systemd[1]: Starting MariaDB 10.3.22 database serv>
May 10 12:19:18 chale-server mysqld[38264]: 2020-05-10 12:19:18 0 [Note] /usr/s>
May 10 12:19:19 chale-server systemd[1]: mariadb.service: Main process exited, >
May 10 12:19:19 chale-server systemd[1]: mariadb.service: Failed with result 'e>
May 10 12:19:19 chale-server systemd[1]: Failed to start MariaDB 10.3.22 databa>

输出journalctl -xe为:

May 10 12:19:19 chale-server systemd[1]: mariadb.service: Main process exited, >
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- An ExecStart= process belonging to unit mariadb.service has exited.
-- 
-- The process' exit code is 'exited' and its exit status is 1.
May 10 12:19:19 chale-server systemd[1]: mariadb.service: Failed with result 'e>
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit mariadb.service has entered the 'failed' state with result 'exit-co>
May 10 12:19:19 chale-server systemd[1]: Failed to start MariaDB 10.3.22 databa>
-- Subject: A start job for unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit mariadb.service has finished with a failure.
-- 
-- The job identifier is 6206 and the job result is failed.
May 10 12:19:19 chale-server polkitd(authority=local)[859]: Unregistered Authen>

其他信息

我不确定是否应该包括我ssh使用我的 macbook 通过连接运行服务器...

答案1

执行systemctl start mariadb,然后重试。看起来 MariaDB 从未启动过。

相关内容