最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】crifan.com网站无法打开:建立数据库连接时出错

crifan.com crifan 2932浏览 0评论

访问主页

crifan.com

突然出现问题:

Safari无法访问

试了试chrome可以

以及是翻墙的原因,结果全局翻墙,Safari还是无法访问:

Safari 浏览器无法打开页面 “https://www.crifan.com/”。 错误是:“FetchEvent.respondWith received an error: Returned response is null.” (WebKitServiceWorker:0)

然后去Chrome中打开某个具体页面,发现有问题:

无法打开:

想要进入后台,结果显示

建立数据库连接时出错
这意味着您在wp-config.php文件中指定的用户名和密码信息不正确,或我们未能在localhost联系到数据库服务器。这可能意味着您主机的数据库服务器未在运行。
* 您确定用户名和密码正确吗?
* 您确定输入的主机名正确吗?
* 您确定数据库服务器在运行吗?

如果您不明白这些意味着什么,您应该联系您的主机提供商。如果您仍需要帮助,请访问WordPress支持论坛。

感觉像是服务器中mysql数据库挂了?

去看看

Last failed login: Thu Oct 17 10:39:31 CST 2019 from 61.28.227.133 on ssh:notty
There were 134679 failed login attempts since the last successful login.
Last login: Wed Jul 31 10:31:54 2019 from 222.92.130.218
[root@crifan ~]#

登录后台

centos check mysql

HowTo: Find out If MySQL Is Running On Linux Or Not – nixCraft

mysqladmin -u root -p status

结果:

[root@crifan ~]# mysqladmin -u root -p status
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

Show (List) MySQL Databases on Linux via Command Line | Liquid Web

[root@crifan ~]# mysql -u root -p 
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

How do You Know if MySQL is Running on CentOS 7?

[root@crifan ~]# top | grep mysql

[root@crifan ~]#

另外:

[root@crifan ~]# systemctl status mysqld
● mysqld.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: active (exited) since Wed 2019-07-31 10:30:10 CST; 2 months 17 days ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2999 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)

Oct 16 05:20:26 crifan.com mysqld[2999]: /usr/local/mysql/bin/mysqld_safe: line 199:  4057 Killed                  nohup /usr/local/mysql/bin/mysqld –basedir=/usr/l…

Oct 16 05:43:06 crifan.com mysqld[2999]: /usr/local/mysql/bin/mysqld_safe: line 199: 13049 Killed                  nohup /usr/local/mysql/bin/mysqld –basedir=/usr/l…

Oct 16 05:43:31 crifan.com mysqld[2999]: /usr/local/mysql/bin/mysqld_safe: line 199: 13452 Killed                  nohup /usr/local/mysql/bin/mysqld –basedir=/usr/l…

Hint: Some lines were ellipsized, use -l to show in full.

感觉是:

已经退出了。

那强制关闭再启动

[root@crifan ~]# systemctl stop mysqld
[root@crifan ~]# systemctl start mysqld
[root@crifan ~]# systemctl status mysqld 
● mysqld.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: active (running) since Thu 2019-10-17 10:45:36 CST; 3s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 405 ExecStop=/etc/rc.d/init.d/mysqld stop (code=exited, status=0/SUCCESS)
  Process: 442 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mysqld.service
           ├─ 455 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/mysql.pid
           └─1306 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/dat...

Oct 17 10:45:34 crifan.com systemd[1]: Starting LSB: start and stop MySQL…

Oct 17 10:45:36 crifan.com mysqld[442]: Starting MySQL..[  OK  ]

Oct 17 10:45:36 crifan.com systemd[1]: Started LSB: start and stop MySQL.

再去访问访问看看

就正常了:

【总结】

此处访问crifan.com的WordPress网站出现

建立数据库连接时出错

原因是:

mysql数据库(异常)退出了

但是什么原因导致退出的,不知道。

解决办法:

重新启动

systemctl stop mysqld
systemctl start mysqld

然后通过:

systemctl status mysqld

确认状态是:

active (running)

即可。

另外:

systemctl status mysqld
<p>...</p><p>   Active: active (exited) since Wed 2019-07-31 10:30:10 CST; 2 months 17 days ago</p>

看到是:

之前异常状态

active (exited) = 有效但是却退出了的

难道是 2个多月之前就出现了?

那最近网站貌似没什么问题的,只是这几天出现问题的。

难道是是 mysql状态是 active (exited),也都可以正常运行(很长时间)?

转载请注明:在路上 » 【已解决】crifan.com网站无法打开:建立数据库连接时出错

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
88 queries in 0.195 seconds, using 22.02MB memory