Thursday, July 2, 2015

Wordpress with MySQL: Error establishing a database connection

The Problem

I ran into the following problem today when I was setting up a fresh local wordpress install on my Mac.


"Error establishing a database connection
This either means that the username and password information in your wp-config.php file..."
Fortunately, the fix was pretty simple!

The Fix

First, check if MySQL is running:
In terminal, I typed
mysqladmin version

If the server is running, the above command should return something like:

So the server is running, and I'm 100% sure I have the right username and password. So, what's the problem?
On a whim, I found the fix:
In /<wordpress folder>/wp-config.php, change the line
define('DB_HOST', 'localhost');
to
define('DB_HOST', '127.0.0.1');

That fixed the problem! :)

No comments:

Post a Comment