logo

$10
Why would WordPress fail to connect to database?

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

Lawrence Krubner | 04/29/11 at 4:04pm | Edit

Previous versions of this question: 04/29/11 at 4:56pm

(3) Possible Answers Submitted...

  • avatar
    Last edited:
    04/29/11
    4:13pm
    Michael Fields says:

    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 :(

    • 04/29/11 4:57pm

      Lawrence Krubner says:

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

    • 04/29/11 4:59pm

      Lawrence Krubner says:

      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.

    • 04/29/11 5:01pm

      Lawrence Krubner says:

      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

  • avatar
    Last edited:
    04/29/11
    4:15pm
    Hardeep Singh says:

    Hello,

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

    Are you able to connect usimg PHPMyAdmin?

    - Hardeep

  • avatar
    Last edited:
    04/29/11
    4:25pm
    Lew Ayotte says:

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

    • 04/29/11 4:58pm

      Lawrence Krubner says:

      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.

This question has expired.



Lawrence Krubner voted on this question.



Current status of this question: Completed