Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • I was hoping for a reply to dadio’s post above but finally I tinkered enough to figure it out for myself. I’m not sure of the proper way to reference another post, but if you search for:

    Error Establish a databese connection
    by “nelsonov” (that’s me)

    You’ll find in the 2nd post how I hacked wp-db.php to give the actual error during the database connect. Noticed that I goofed and spelled my post with “Establish” instead of “Establishing”. That might make it easier to find.

    Good luck.

    Thread Starter nelsonov

    (@nelsonov)

    I finally managed to answer my own question. The short answer is that for some reason PHP was logging in with the full domain name of the web server rather than as ‘localhost’, so I needed a user like this:

    ‘wordpress’@’fqdn.myserver.com’
    instead of
    ‘wordpress’@’localhost’

    I discovered this by tampering with my wp-db.php in wp-includes. I’m not a PHP programmer, so I’m sure there’s a better way to do this, but this worked for me. All the changes are near the top of the script (BTW, this is WordPress 2.0.1), so I’ll just show the pertinent part:

    class wpdb {

    var $show_errors = true;
    var $num_queries = 0;
    var $last_query;
    var $col_info;
    var $queries;

    // Our tables
    var $posts;
    var $users;
    var $categories;
    var $post2cat;
    var $comments;
    var $links;
    var $linkcategories;
    var $options;
    var $optiontypes;
    var $optionvalues;
    var $optiongroups;
    var $optiongroup_options;
    var $postmeta;
    var $my_errstr;

    // ==================================================================
    // DB Constructor – connects to the server and selects a database

    function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
    $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
    if (!$this->dbh) {
    $my_errstr=mysql_error();
    $this->bail(“
    <h1>Error establishing a database connection</h1>
    This either means that the username and password information in your wp
    -config.php
    file is incorrect or we can’t contact the database server at
    $dbhost. This could mean your host’s database server is down.

    • Are you sure you have the correct username and password?
    • Are you sure that you have typed the correct hostname?
    • Are you sure that the database server is running?

    If you’re unsure what these terms mean you should probably contact your host.
    If you still need help you can always visit the <a href=’https://www.ads-software.com/s
    upport/’>WordPress Support Forums.
    Error: $my_errstr;
    “);

    The parts I added are the three lines with “$my_errstr”. This printed out the exact database error. This might be something that the WordPress developers could consider implementing (with better coding) in future releases. It could save people many hours of head scratching.

Viewing 2 replies - 1 through 2 (of 2 total)