$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Error establishing a database connection in wordpress|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Error establishing a database connection in wordpress

matteradmin9PV0评论

I know this is self explanatory but why can't I connect to my database? I have a live website that I wanted to update by first doing development in my local computer. I exported the db to my local pc then imported it to phpmyadmin. When I try to access the site thru localhost/sitename, the error Error establishing a database connection keeps popping up.

I have tried every tutorial and forums out there but still the error persists. I have checked the credentials from wp-config.php and it was the same(same db name, username, password). Is there other contents should I change property?

Thanks in advance!

I know this is self explanatory but why can't I connect to my database? I have a live website that I wanted to update by first doing development in my local computer. I exported the db to my local pc then imported it to phpmyadmin. When I try to access the site thru localhost/sitename, the error Error establishing a database connection keeps popping up.

I have tried every tutorial and forums out there but still the error persists. I have checked the credentials from wp-config.php and it was the same(same db name, username, password). Is there other contents should I change property?

Thanks in advance!

Share Improve this question asked Mar 11, 2019 at 1:34 marvin castromarvin castro 354 bronze badges 1
  • Make sure MySQL user you have created is configured to connect using "localhost" in the hostname, NOT "%". Go to PHPMyAdmin -> Users -> Make sure your user is set to connect using "localhost" rather than "%". – Kinnectus Commented Mar 11, 2019 at 13:52
Add a comment  | 

1 Answer 1

Reset to default 0

I had this issue some days ago with a multisite, loading a live dump to local development. After some debugging I noticed, that the error message wasn't right.
The database was connected, but the path in the database to the sites was wrong.
You can check table <your-prefix>_site and <your-prefix>_blogs if columns domain and path are correct.
That solved my problem, as the error message told something else.

Post a comment

comment list (0)

  1. No comments so far