2

WordPress的Error establishing a database connection错误修复

 1 year ago
source link: https://www.daguanren.cc/post/wp_database_error.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
04月22, 2018

WordPress的Error establishing a database connection错误修复

在使用WordPress的时候,我们经常会遇到Error establishing a database connection的错误,导致主页无法访问。类似下图:

那么如何解决呢?

nano /usr/share/nginx/html/wp-config.php#在文件最末端增加/* That's all, stop editing! Happy blogging. */define('WP_ALLOW_REPAIR',true);vala

http://你的域名/wp-admin/maint/repair.php 点击修复并优化数据库按钮进行修复。

alt

之后移除增加的代码

define('WP_ALLOW_REPAIR',true);

如果还是不能解决,请再次打开WordPress配置文件wp-config.php,确认如下数据库配置是正确的:

define('DB_NAME', 'database-name');define('DB_USER', 'database-username');define('DB_PASSWORD', 'database-password');define('DB_HOST', 'localhost');lasso

其中的HOST配置可以尝试改为IP+端口号的形式

define('DB_HOST', '127.0.0.1:8889');

然后确认数据库的用户名和密码正确。可以尝试命令行先用填写的数据库用户名和密码登陆,确保可以登陆成功。

如果还是不行,请尝试重启以下三个服务:

systemctl restart mysqlsystemctl restart php-fpm.servicesystemctl restart nginx

http://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/

本文链接:https://www.daguanren.cc/post/wp_database_error.html

-- EOF --

作者 daguanren

发表于 2018-04-22 17:16:19

,添加在分类 技术分享 WordPress

,并被添加「 MySQL WordPress 」标签

,最后修改于 2018-04-22 18:10:05

版权归本网站的作者所有,转载请注明出处,谢谢大家。 问题咨询和商务合作请发送邮件至[email protected]


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK