WP development locally – Error establishing a database connection

I’m using Linux Mint 13 (Ubuntu 12.04 based) and trying to install a local development environment of a WordPress production project which right now is in an amazon EC2 instance.

First, I cloned WP project from its bitbucket repository.

Read More

After, I made a db environment backup with:

mysqldump -u root -p --lock-tables=false --all-databases > dump-$( date '+%Y-%m-%d_%H-%M-%S' ).sql

Then I imported it to my computer with:

 scp my-server:~/db_backups/db_backup.sql ~/mylocalfolderforbackups

I installed the db environment backup in my local mysql with:

 mysql -u root -p < db_backup.sql

My wp-config.php is filled as following (thought I don’t know if my WP copy uses wp-config.php.prod instead):

define('DB_NAME', 'prod_db'); //because I've restored the production db backup
define('DB_USER', 'root');
define('DB_PASSWORD', 'password'); //where I put the right password for root user
define('DB_HOST', 'localhost');
define('WP_HOME', 'http://localhost');
define('WP_SITEURL', 'http://localhost');

I’ve restarted apache and mysql but when I try to access to http://localhost/my-project/ it returns “Error establishing a database connection”. I don’t find the issue… Do you have an idea? Thank you.

Related posts

2 comments

  1. You need to know the name of the mysql database used by wordpress and set the DB_NAME in your wp-config.

  2. Error establishing a database connection doesn’t get any simpler than that. Your password, database name, user name, or host is wrong. WordPress won’t use wp-config.php.prod, only wp-config.php. See http://codex.wordpress.org/Common_WordPress_Errors#Error_Establishing_Database_Connection

    Try

    mysql> show databases;

    to list all databases to check the database name.

    Try

    mysql> mysqlserverinfo --server=root:pass@localhost -d --format=vertical

    to get port info, etc. See http://dev.mysql.com/doc/mysql-utilities/1.6/en/mysqlserverinfo.html

    Or, try using Adminer http://www.adminer.org/ on your PC/Mac to find the database name, etc.

Comments are closed.