WP Development Locally - Error Establishing Database Connection
I am using Linux Mint 13 (based on Ubuntu 12.04) and am trying to install a local development environment for a WordPress project that is currently on an EC2 Amazon instance.
First, I cloned the WP project from my bitbucket repository.
After that, I created a backup of the db environment 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 have set up a backup of the db environment in my local mysql with:
mysql -u root -p < db_backup.sql
My wp-config.php is populated like this (I guess I don't know if my copy of WP is using 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 restarted apache and mysql, but when I try to access http: // localhost / my-project / it returns "Error while establishing database connection". I can't find the question ... Do you have an idea? Thank.
source to share
Error establishing a database connection
doesn't get easier. Invalid password, database name, username, or hostname. 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 view all databases to check the name of the database.
Try
mysql> mysqlserverinfo --server=root:pass@localhost -d --format=vertical
to get information about the port, 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.
source to share