Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Why would WordPress fail to connect to database? WordPress

  • SOLVED

I'm developing on a Linux machine, connected over a network to other servers, including the database server.

I've a site, originally Lyceum and then upgraded to WordPress 3.

I get "Error establishing database connection".

If I open wp-config.php and echo the db name, password, user and host to the screen, and copy and paste all this to a terminal and try to reach mysql from the terminal, then everything works fine. I can get into Mysql from the terminal.

I also have other PHP projects on this computer that are reaching the same database servers with no problem.

But this WordPress project, despite having valid credentials in wp-config.php, is not reaching those servers.

Why?


[UPDATE]

If I point my browser at wp-admin/install.php, on my local machine, I get:

Notice: Trying to get property of non-object in /usr/local/src/st/workspace/trunk/build/blogs/wp-includes/ms-settings.php on line 107
Notice: Trying to get property of non-object in /usr/local/src/st/workspace/trunk/build/blogs/wp-includes/ms-settings.php on line 108
Notice: Undefined property: stdClass::$deleted in /usr/local/src/st/workspace/trunk/build/blogs/wp-includes/ms-load.php on line 53
Notice: Undefined property: stdClass::$deleted in /usr/local/src/st/workspace/trunk/build/blogs/wp-includes/ms-load.php on line 62
Notice: Undefined property: stdClass::$archived in /usr/local/src/st/workspace/trunk/build/blogs/wp-includes/ms-load.php on line 69
Notice: Undefined property: stdClass::$spam in /usr/local/src/st/workspace/trunk/build/blogs/wp-includes/ms-load.php on line 69

Answers (3)

2011-04-29

Michael Fields answers:

Is it possible that you have a wp-config.php one directory above your installation that has bunk credentials in it? WordPress will use this instead of the wp-config in the actual installation. I lost about 30 minutes to this one day :(


Lawrence Krubner comments:

Interesting. There are a lot of symlinks that stitch the system together. I'll keep this in mind.


Lawrence Krubner comments:

Do you happen to know where the error "Error establishing database connection" is triggered? It would be interesting to hack to that point and then check the config parameters right there.


Lawrence Krubner comments:

Huh.


grep -iR "Error establishing database connection" *

blogs/wp-includes/ms-load.php: $title = /*WP_I18N_FATAL_ERROR*/'Error establishing database connection'/*/WP_I18N_FATAL_ERROR*/;

grep: blogs/wp-content/blogs.dir: No such file or directory

2011-04-29

Hardeep Singh answers:

Hello,

Please check, if user is allowed to access from other systems.

Are you able to connect usimg PHPMyAdmin?

- Hardeep


Lawrence Krubner comments:

I'm able to connect from the terminal.

2011-04-29

Lew Ayotte answers:

Also, If the MySQL Database is over the network and the site's IP address is not allowed to connect, it may have trouble.


Lawrence Krubner comments:

But I have other PHP projects on my machine that are connecting. Obviously, they all have the same IP, they are all coming from my machine.