Reputation: 5540
I tried installing Drupal on my local server, and everything worked fine. I installed Drupal on my localhost, and then I tried to transfer the same Drupal directory on my server using FileZilla. Changed my settings.php
file in accordance to my server MySql settings as follows:
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'manas_drupal',
'username' => 'XXXXXXX',
'password' => 'XXXXXXX',
'host' => '127.0.0.1',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
However, when I tried accessing the website where the Drupal installation should have been present, I encounter the following error:
PDOException: SQLSTATE[HY000] [2002] Connection refused in lock_may_be_available() (line 167 of /home/manasge/manas.getevangelized.com/drupal/includes/lock.inc).
Now, line 167 of lock.inc
contains the following function:
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;
}
What seems to be wrong here? Everything works fine on my localhost, but I can't seem to get this thing working on my main host. For reference, this is the link where my Drupal directory is hosted: http://manas.getevangelized.com/drupal/
Also, I have an empty database named manas_drupal
defined in PHPMyAdmin already. Also, I made sure that the username and password for MySQL in settings.php
were entered correctly.
Upvotes: 2
Views: 20869
Reputation: 1215
This happened to me because the server that was running MySQL had killed off the process, although the specifics of why this happened are not relevant. When my instance of drupal went to connect to the database it was given 'Connection Refused'.
I then attempted to directly connect to the database but I had similar issues connecting. A thread I found here suggested restarting MySQL. When I checked the status of MySQL it gave me the following error:
$ sudo service mysql status
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
After restarting it, my drupal instance worked as normal again.
Upvotes: 6
Reputation: 581
Your database shouldn't be empty, export your database from localhost and import it in your empty database in your online server.
Upvotes: 0