No, not in the zombie sense. The blog has been offline for a while now, if you came to visit you just received "Error establishing a database connection". So I finally got around to looking at it today, and it took a little digging but wasn't as painful as I thought it might be. Apparently, the most common causes of this error are:

  • Incorrect username or password.
  • Incorrect database name
  • Incorrect database server hostname.

These settings are all in wp-config.php:

// ** MySQL settings ** //
define('DB_NAME', '***');    // The name of the database
define('DB_USER', '***');     // Your MySQL username
define('DB_PASSWORD', '***'); // ...and password
define('DB_HOST', '***');    // 99% chance you won't need to change this value

I could connect to my hosting company's MySql admin tool and it was easy to verify that these were all correct. So, next step was to write a small php script that could connect to the database:

<?php
$link = mysql_connect('*host*', '*user*', '*password*');
if (!$link) { die('Could not connect: ' . mysql_error()); }
echo 'Connected successfully\n';
$db_selected = mysql_select_db(*database*, $link);
if (!$db_selected) { die ('Can\'t use foo : ' . mysql_error()); }
echo 'DB Selected successfully\n';
$sql = "SHOW TABLES FROM *database*";
$result = mysql_query($sql);
if (!$result) { echo "DB Error, could not list tables\n"; echo 'MySQL Error: ' . mysql_error(); exit; }
while ($row = mysql_fetch_row($result)) { echo "Table: {$row[0]}\n"; }
mysql_free_result($result); ?>

(PHP is not my strongest language so this was just built from snippets gleaned from t'interweb) This all worked fine. I eventually found this thread that pointed me in the right direction - my database permissions had somehow been screwed up (don't ask me how), so I reset them to what Wordpress needs and voila. And the first thing I notice is that Wordpress needs upgrading - next post...