Drupal:PDOException:SQLSTATE [HY000] [2002]连接被拒绝lock_may_be_available()
问题描述:
我试着在我的本地服务器上安装Drupal,并且一切正常。我在本地主机上安装了Drupal,然后尝试使用FileZilla在我的服务器上传输相同的Drupal目录。改变了我的settings.php
文件按照我的服务器MySql的设置如下:Drupal:PDOException:SQLSTATE [HY000] [2002]连接被拒绝lock_may_be_available()
$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/
另外,我有一个名为manas_drupal
的空数据库,已在PHPMyAdmin中定义。另外,我确认在settings.php
中正确输入了MySQL的用户名和密码。
答
您的数据库不应该为空,从localhost导出数据库并将其导入到您的在线服务器的空数据库中。