duanmianhong4893 2014-06-23 04:12
浏览 42

在wordpress多站点中经常建立数据库连接错误

I am having a multisite network hosted on cloud. I came across the error "Error establishing a database connection" both in front and back end for the 2nd time.First time i just restarted the server and the problem was solved, now the issue came back again after couple of weeks. This time i didnt tried restarting instead am trying to find the cause. Since am planning to have more users in my site i think its not fair to keep on restarting the server.

I belive my wp-config is fine.At this stage i tried to test the db connection using following piece of code.

`<?php
$link = mysql_connect('localhost', '*******', '*****');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>`

and added this file to my www folder. when i run the file shows "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)" Can someone please help me with this...

Thanks in advance :)

  • 写回答

1条回答 默认 最新

  • doutu1889 2015-12-28 09:55
    关注

    I have faced this issue in wordpress, Just follow the below steps to fix the issue.

    Add this code in wp-config.php

    define(‘WP_ALLOW_REPAIR’, true);
    

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏