简体   繁体   English

建立数据库连接时出错

[英]Error establishing in database connection

I have a Wordpress site which works perfectly. 我有一个完美运行的Wordpress网站。 But some times when I refresh the page several times using F5 key, then my site goes down for several minutes or for about half an hour and shows message 但是有时候,当我使用F5键几次刷新页面时,我的站点关闭了几分钟或大约半个小时,并显示消息

"Error establishing in database connection". “在数据库连接中建立错误”。

My database user name , password , host etc all are right. 我的数据库用户名,密码,主机等都正确。 And my site works perfectly. 而且我的网站运行良好。 But it shows this error only some times. 但是它仅在某些时候显示此错误。 If database connection are not perfect then it must show this message all the time. 如果数据库连接不完美,则它必须一直显示此消息。 I have also written custom database connection in seperate files. 我还用单独的文件编写了自定义数据库连接。

Most of the time this error message is caused by a problem in the wp-config file. 大多数情况下,此错误消息是由wp-config文件中的问题引起的。

Add this code in wp-config.php wp-config.php中添加此代码

define('WP_ALLOW_REPAIR', true);

yourdomain.com/wp-admin/maint/repair.php yourdomain.com/wp-admin/maint/repair.php

Click repair and optimize button to repair your database. 单击修复和优化按钮以修复数据库。

Make sure you remove this line of code after you have fixed your database connection error message. 修复数据库连接错误消息后,请确保删除此行代码。

If you still have this issues, contact your hosting provider. 如果仍然有此问题,请与您的主机提供商联系。 They will fix this easily. 他们将轻松解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM