This is driving me nuts! I have a test instance of WordPress installed on my MacBook Pro, which has suddenly stopped working. If I head for http://localhost:9003/wp-admin/ I get:
Error establishing a database connection
This either means that the
username and password information in
your wp-config.php file is incorrect
or we can’t contact the database
server at localhost. This could mean
your host’s database server is down.Are you sure you have the correct
username and password?Are you sure
that you have typed the correct
hostname?Are you sure that the
database server is running?If you’re
unsure what these terms mean you
should probably contact your host. If
you still need help you can always
visit the WordPress Support Forums.
Hmmph! I haven’t touched the config for ages. Here’s how the relevant lines look right now:
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'wordpress');
define('DB_HOST', 'localhost');
$table_prefix = 'wp_';
The values are all good:
$ mysql -h localhost -u wordpress --password=wordpress \
> wordpress -e 'select user_login from wp_users'
+------------+
| user_login |
+------------+
| simon |
+------------+
There’s nothing in the MySQL error log, nor in Apache’s error log. I’ve tried using a different MySQL user and a different database, but I get the same error. I’m scuppered – any WordPress gurus out there know what I’m missing?
Output of php –ri mysql:
$ php --ri mysql
mysql
MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $
Directive => Local Value => Master Value
mysql.allow_persistent => On => On
mysql.max_persistent => Unlimited => Unlimited
mysql.max_links => Unlimited => Unlimited
mysql.default_host => no value => no value
mysql.default_user => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysql.connect_timeout => 60 => 60
mysql.trace_mode => Off => Off
mysql.allow_local_infile => On => On
This is exactly the problem, and the solution.
http://appletoolbox.com/2010/08/phpmysql-broken-after-security-update-2010-05-fix/