I just installed drupal.
The following error appears at every page:

Warning: Can't connect to MySQL server on 'localhost' (111) in /blah/blah/websites/drupal/includes/database.mysql.inc on line 47

Warning: MySQL Connection Failed: Can't connect to MySQL server on 'localhost' (111) in /blah/blah/websites/drupal/includes/database.mysql.inc on line 47

Warning: MySQL: A link to the server could not be established in /blah/blah/websites/drupal/includes/database.mysql.inc on line 47

Fatal error: Can't connect to MySQL server on 'localhost' (111) query: INSERT INTO watchdog (uid, type, message, location, hostname, timestamp) VALUES ('1', 'error', 'warning: Can\'t connect to MySQL server on \'localhost\' (111) in /blah/blah/websites/drupal/includes/database.mysql.inc on line 47.', '/drupal/cron.php', 'XX.XX.72.12', '1028551061') in /blah/blah/websites/drupal/includes/database.mysql.inc on line 57

My problem is, that my database-server is not 'localhost', it is an IP. I think drupal wants to use 'localhost' and - of course - can't do that. Can anyone help me, please?

Comments

ffng’s picture

Try to edit the conf.php file under the includes directory:

# $db_url = "pgsql://user:password@hostname/database";

You can use IP addess in "hostname", such as:

$db_url = "mysql://ffng:password@123.123.1.2/drupal";

MarS-1’s picture

I did that. There is already some data in the watchdog. Don't ask me why the error is printed... Only local images are allowed.

ffng’s picture

My suggestion may not correct. I encountered similiar problem when I restored an old database to replace the original (in Win32 environment). Both MySQL and PHP are running. In order to reconnect the database, I have to run the "GRANT ALL" command again in MySQL.

See: Handbook page

about:
type: GRANT ALL ON drupal.* TO username@localhost IDENTIFIED BY 'password';

PiAir’s picture

Ignore.. (or delete)