Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm wanting to make a version of my blog on my home computer that I can work on offline. I set up LAMP on my computer (running Ubuntu) and copied all of my files from my server (000 Webhost) with FileZilla. But when I try to access my site on my localhost, I get "Error establishing a database connection." I think I've figured out that it has something to do with MySQL, but I'm really new to all this and could be way off. Any help would be greatly appreciated. Thanks in advance.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Did you change your database settings in wp_config.php and copy your database to your local machine? You'll also need to use a text editor to search a dump of your database for any URLs pointing to the live site before importing it locally if you haven't done so already.

share|improve this answer
add comment

Change below setting in wp-config.php for local settings.

/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', '');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** MySQL dbname*/
define('DB_NAME', 'your_db_name');

Also you need to do find & replace for url (for e.g. Replace http://yourdomain.com to your localhost your_project_url in the dump sql file. then import that sql file to your_db_name

Done...!!!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.