WordPress.org

Forums

[resolved] Error establishing a database connection (4 posts)

  1. wp3zzz
    Member
    Posted 2 years ago #

    trying to move the site from a server running MySQL 6.0.11-alpha to a server running the CentOS MySQL 5.0.95 Source distribution.

    At first, the user could not connect to this database from cmd line. Then I ran mysql_upgrade and now the user can connect from command line. But I still get the dreaded "Error establishing a database connection"

    That message, "Error establishing a database connection", usually means one of two things:
    1. Database server is down (not operating)
    2. You have wrong information in your wp-config.php--either the DB_HOST, DB_USER, DB_PASSWORD, or DB_NAME is incorrect.

    I have verified that neither of these apply. The database is up and I copied and pasted the values from wp-config to command line and they now connect successfully from cmd line, but not if i run php index.php from cmd line - that gives the db error.

    I tried resetting the MySQL user's password (with PASSWORD and OLD_PASSWORD, followed by FLUSH PRIVILEGES), tried re-issuing the GRANT statement. But I get the error no matter what, whereas other wordpress sites worked even before the mysql_upgrade - very strange.

    Thanks in advance for any suggestions!
    Joe

  2. Pioneer Web Design
    Member
    Posted 2 years ago #

    I have verified that neither of these apply.

    Remove all capitals from db UN and PW in wp-config.php even if allowed at MySQL setup..

  3. wp3zzz
    Member
    Posted 2 years ago #

    Thanks for the suggestion, tried that but got the same result. Now I enabled debug in wp-config and see this;

    Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in /wp-includes/wp-db.php on line 1141

    not sure why only this user is affected, but thanks to this clue, I finally did find the solution. In my.cnf was 'old_passwords=1', so I had to comment it out and then had to update the user's password as above, flush privileges, woo hoo it works!

  4. Yui
    Member
    Posted 2 years ago #

    >not sure why only this user is affected

    user password has created long time ago and password wasnt changed since ..... long time,
    so the password hash is old, and not supported by mysqlnd php driver, only by mysqlclient library, your host has php updated with mysqlnd enabled. Its OK.

    Just change password for user and disable old_passwords=1

Topic Closed

This topic has been closed to new replies.

About this Topic