# Solved: problem connecting to database on existing WordPress website when working loc



## SiteSubscribe (May 18, 2011)

I brought a live existing WordPress site down to my local Mac to work on it within a local development environment (my first venture into this).

But I'm having trouble connecting to the local instance of MySQL through WordPress (I think) for this existing site (I was able to get a new install of WordPress working fine locally, but having trouble with an existing site).

I'm getting '*Error establishing a database connection*'.

My server hostname (*dev.site*) that I set up with MAMP PRO is going to the local site like it should.

But the local install of WordPress just is not making the local SQL connection properly (from what I can tell).

I've tried changing a few things (like removing the 'base' or 'path' references within wp-config) and nothing works. If I connect to the remote database (by updating the wp-config and MySQL values below to the remote connections) for this site it works fine.

_See anything screwy here??_

*Here are the wp-config & MySQL settings:*

/* LOCAL WP-CONFIG ***************************************************************/
define('DB_NAME', 'WordPress');
define('DB_USER', 'local-mysql-username');
define('DB_PASSWORD', 'local-mysql-password');
define('DB_HOST', 'localhost');
define('DOMAIN_CURRENT_SITE', 'dev.site' );
define('PATH_CURRENT_SITE', '/test/' ); /* this is how the original live site was set up and working */
/*END// LOCAL WP-CONFIG ***************************************************************/

/* LOCAL MySQL ***************************************************************/
/* this is an old WPMU 2.9.1 install, so the table names are slightly different than the current version of WordPress */
/*
tables: wp_sites & wp_blogs
domain: dev.site
path: /test/
*/
/*END// LOCAL MySQl ***************************************************************/

$base = '/test/';

Thanks for any help you can offer.

~Jeff


----------



## SiteSubscribe (May 18, 2011)

I was able to connect by changing:

define('DB_HOST', 'localhost');

to 

define('DB_HOST', '127.0.0.1');


----------

