I am facing 'error establishing a database connection', while I am trying to visit my site in browser. I am working in WordPress that is installed in my local computer. I have already done following things to troubleshoot:

1. Checked the correctness of my DB_Name, DB_User, DB_Password and DB_Host. (To do this I have used a php script to connect to database. By that script I could successfully connect to database. So my credentials are surely Okay.)
2. Also tried to put DB_Host as '' and 'localhost:3306'
3. I have also changed the MySQL Port(3306) to other values (as for example to 3307).

None of above steps was successful to solve my problem. This error is very notorious error of WordPress platform. Can any body have any solution.

  • Can you please tell us what you are using to run your local enviroment e.g. MAMP? – Sam Sep 21 '16 at 13:51

did you change or modify any core WordPress files? just make sure that core files are not modified. and i suggest you to double check the wp-config.php file for DB Configurations.

restart your local server (apache & php).

Try with following configuration.

DB USER: 'root'
DB PASS: '' (blank)
  • Hello Rehman, I tried your suggested solutions. But those were not effective for my case. But helped to work out solution. Thanks for your suggestion. I solved my problem by following way: Opened the phpMyAdmin> selected the appropriate the WordPress Database> made sure the structure tab is selected > selected all the tables> clicked the drop-down box (of which caption is 'with selected:') > selected the option 'Repaid table'. – Zubair Sep 27 '16 at 7:14

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