在没有pw的情况下连接到MySQL-无法通过套接字'/var/run/mysqld/mysqld.sock'(2)连接到本地MySQL服务器

时间:2019-08-25 15:43:46

标签: php mysql wordpress sockets

我有一个曾经可以正常运行的Wordpress网站,但是最近尝试导航到该网站时,我收到消息“建立数据库连接时出错”。在网上研究后,我意识到这可能与更改我的数据库密码有关。

因此,我正在遵循有关从此处-https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password重置Mysql pw的说明。

步骤:

sudo systemctl stop mysql

sudo mysqld_safe --skip-grant-tables --skip-networking &

输出:

2019-08-25T15:23:22.702830Z mysqld_safe Logging to syslog.
2019-08-25T15:23:22.707805Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2019-08-25T15:23:22.712056Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

然后我做

mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld

然后运行 sudo mysqld_safe --skip-grant-tables --skip-networking &

输出

2019-08-25T15:33:49.404761Z mysqld_safe Logging to syslog.
2019-08-25T15:33:49.411891Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2019-08-25T15:33:49.443922Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2019-08-25T15:33:49.992471Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

在这里,我做mysql -u root,然后看

输出:

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

到目前为止,故障排除已完成

要进行故障排除,我按照建议from this post查找了袜子文件。我尝试通过

sudo find / -type s查找mysql.sock文件,但不在列表中找到它。

输出:

/run/acpid.socket
/run/dbus/system_bus_socket
/run/snapd-snap.socket
/run/snapd.socket
/run/uuidd/request
/run/user/0/systemd/private
/run/user/0/systemd/notify
/run/fail2ban/fail2ban.sock
/run/lvm/lvmpolld.socket
/run/lvm/lvmetad.socket
/run/systemd/journal/dev-log
/run/systemd/journal/socket
/run/systemd/journal/stdout
/run/systemd/journal/syslog
/run/systemd/private
/run/systemd/notify
/run/udev/control
/var/lib/lxd/unix.socket
/var/spool/postfix/private/proxywrite
/var/spool/postfix/private/relay
/var/spool/postfix/private/ifmail
/var/spool/postfix/private/retry
/var/spool/postfix/private/defer
/var/spool/postfix/private/maildrop
/var/spool/postfix/private/mailman
/var/spool/postfix/private/discard
/var/spool/postfix/private/anvil
/var/spool/postfix/private/scalemail-backend
/var/spool/postfix/private/bsmtp
/var/spool/postfix/private/bounce
/var/spool/postfix/private/verify
/var/spool/postfix/private/trace
/var/spool/postfix/private/uucp
/var/spool/postfix/private/lmtp
/var/spool/postfix/private/local
/var/spool/postfix/private/error
/var/spool/postfix/private/rewrite
/var/spool/postfix/private/proxymap
/var/spool/postfix/private/smtp
/var/spool/postfix/private/tlsmgr
/var/spool/postfix/private/scache
/var/spool/postfix/private/virtual
/var/spool/postfix/public/showq
/var/spool/postfix/public/qmgr
/var/spool/postfix/public/pickup
/var/spool/postfix/public/cleanup
/var/spool/postfix/public/flush
/var/spool/postfix/dev/log

我尝试通过sudo service mysql start重新启动服务器,但得到了此输出

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

systemctl status mysql.service的输出是

 mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Sun 2019-08-25 15:41:53 UTC; 27s ago
  Process: 16974 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 16966 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCE
 Main PID: 16974 (code=exited, status=1/FAILURE);         : 16975 (mysql-systemd-s)
    Tasks: 2
   Memory: 5.1M
      CPU: 331ms
   CGroup: /system.slice/mysql.service
           └─control
             ├─16975 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─17042 sleep 1

Aug 25 15:41:53 keshinpoint systemd[1]: Starting MySQL Community Server...
Aug 25 15:41:53 keshinpoint systemd[1]: mysql.service: Main process exited, code=exited, status=1/F

journalctl -xe的输出为

-- Unit mysql.service has finished shutting down.
Aug 25 21:08:08 keshinpoint systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has begun starting up.
Aug 25 21:08:08 keshinpoint audit[7730]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/
Aug 25 21:08:08 keshinpoint audit[7730]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/
Aug 25 21:08:08 keshinpoint audit[7730]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/
Aug 25 21:08:08 keshinpoint kernel: audit: type=1400 audit(1566767288.456:105247): apparmor="DENIED
Aug 25 21:08:08 keshinpoint kernel: audit: type=1400 audit(1566767288.460:105248): apparmor="DENIED
Aug 25 21:08:08 keshinpoint kernel: audit: type=1400 audit(1566767288.460:105249): apparmor="DENIED
Aug 25 21:08:08 keshinpoint systemd[1]: mysql.service: Main process exited, code=exited, status=1/F
Aug 25 21:08:38 keshinpoint systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has failed.
-- 
-- The result is failed.
Aug 25 21:08:38 keshinpoint systemd[1]: mysql.service: Unit entered failed state.
Aug 25 21:08:38 keshinpoint systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 25 21:08:38 keshinpoint systemd[1]: mysql.service: Service hold-off time over, scheduling resta
Aug 25 21:08:38 keshinpoint systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has finished shutting down.
Aug 25 21:08:38 keshinpoint systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel


-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has finished shutting down.
Aug 25 21:08:38 keshinpoint systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has begun starting up.
Aug 25 21:08:38 keshinpoint audit[7815]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/7815/status" pid=7815 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=112 ouid
Aug 25 21:08:38 keshinpoint kernel: audit: type=1400 audit(1566767318.940:105250): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/7815/status" pid=7815 comm="mysqld" requested_m
Aug 25 21:08:38 keshinpoint audit[7815]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=7815 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=
Aug 25 21:08:38 keshinpoint audit[7815]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/7815/status" pid=7815 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=112 ouid
Aug 25 21:08:38 keshinpoint kernel: audit: type=1400 audit(1566767318.948:105251): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=7815 comm="mysqld" req
Aug 25 21:08:38 keshinpoint kernel: audit: type=1400 audit(1566767318.948:105252): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/7815/status" pid=7815 comm="mysqld" requested_m
Aug 25 21:08:39 keshinpoint systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Aug 25 21:08:44 keshinpoint kernel: [UFW BLOCK] IN=eth0 OUT= MAC=8e:96:82:1a:cc:9e:5c:45:27:78:fb:30:08:00 SRC=81.22.45.100 DST=174.138.62.216 LEN=40 TOS=0x00 PREC=0x20 TTL=245 ID=10892 PROTO=TCP SPT=4071
Aug 25 21:08:47 keshinpoint kernel: [UFW BLOCK] IN=eth0 OUT= MAC=8e:96:82:1a:cc:9e:5c:45:27:78:fb:30:08:00 SRC=51.81.7.101 DST=174.138.62.216 LEN=40 TOS=0x14 PREC=0x00 TTL=246 ID=54321 PROTO=TCP SPT=36258
Aug 25 21:08:53 keshinpoint sshd[7855]: Invalid user www from 51.38.186.228
Aug 25 21:08:53 keshinpoint sshd[7855]: input_userauth_request: invalid user www [preauth]
Aug 25 21:08:53 keshinpoint sshd[7855]: pam_unix(sshd:auth): check pass; user unknown
Aug 25 21:08:53 keshinpoint sshd[7855]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=51.38.186.228
Aug 25 21:08:56 keshinpoint sshd[7855]: Failed password for invalid user www from 51.38.186.228 port 60446 ssh2

在这里感觉就像一个兔子洞。有人可以帮我吗?我将不胜感激,因为我已经尝试了多个stackoverflow帖子中的答案。

0 个答案:

没有答案