Drupal:PDOException:SQLSTATE [HY000] [2002]连接在lock_may_be_available()中被拒绝

问题描述 投票:1回答:2

我尝试在我的本地服务器上安装Drupal,一切正常。我在我的localhost上安装了Drupal,然后我尝试使用FileZilla在我的服务器上传输相同的Drupal目录。根据我的服务器MySql设置更改了我的settings.php文件,如下所示:

$databases = array (
  'default' => 
  array (
    'default' => 
    array (
      'database' => 'manas_drupal',
      'username' => 'XXXXXXX',
      'password' => 'XXXXXXX',
      'host' => '127.0.0.1',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

但是,当我尝试访问应该存在Drupal安装的网站时,我遇到以下错误:

PDOException: SQLSTATE[HY000] [2002] Connection refused in lock_may_be_available() (line 167 of /home/manasge/manas.getevangelized.com/drupal/includes/lock.inc).

现在,lock.inc的第167行包含以下功能:

function lock_may_be_available($name) {
  $lock = db_query('SELECT expire, value FROM {semaphore} WHERE name = :name', array(':name' => $name))->fetchAssoc();
  if (!$lock) {
    return TRUE;
  }
  $expire = (float) $lock['expire'];
  $now = microtime(TRUE);
  if ($now > $expire) {
    // We check two conditions to prevent a race condition where another
    // request acquired the lock and set a new expire time. We add a small
    // number to $expire to avoid errors with float to string conversion.
    return (bool) db_delete('semaphore')
      ->condition('name', $name)
      ->condition('value', $lock['value'])
      ->condition('expire', 0.0001 + $expire, '<=')
      ->execute();
  }
  return FALSE;
}

这里看起来有什么不对?在我的本地主机上一切正常,但我似乎无法在主机上运行这个东西。作为参考,这是我的Drupal目录所在的链接:http://manas.getevangelized.com/drupal/

另外,我已经在PHPMyAdmin中定义了一个名为manas_drupal的空数据库。另外,我确保正确输入settings.php中MySQL的用户名和密码。

php mysql drupal drupal-7
2个回答
2
投票

检查MySQL是否正常运行。

这件事发生在我身上,因为运行MySQL的服务器已经杀掉了这个过程,尽管为什么会发生这种情况的具体细节并不重要。当我的drupal实例连接到数据库时,它被给予'Connection Refused'。

然后我尝试直接连接到数据库,但我有类似的问题连接。我发现here的一个帖子建议重启MySQL。当我检查MySQL的状态时,它给了我以下错误:

$ sudo service mysql status

MySQL没有运行,但是锁文件(/ var / lock / subsys / mysql [FAILED]

重新启动后,我的drupal实例再次正常工作。


0
投票

您的数据库不应为空,从localhost导出数据库并将其导入您的在线服务器的空数据库中。

© www.soinside.com 2019 - 2024. All rights reserved.