WordPress.org

Support

Support » How-To and Troubleshooting » "Error establishing database connection" but script says "connection successful"

"Error establishing database connection" but script says "connection successful"

  • I have imported my site(Wp 3.2.1) to a new Hosting and it is showing “Error establishing a database connection”. The name of the server, user and password are correct. In fact, I am running this script and the answer is “connection succeeded”

    $db = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    if (!$db) echo "connection failed";
    else echo "connection succeeded";

    I cannot access wp-admin either so I have disabled the plugins and set the default theme using phpmyadmin, but no luck. I have also changed the permission flags in the files but still I am getting “Error establishing a database connection”. I have run the database repair script but still not working.

    I have uploaded the site to a free Hosting( freehostia, mysql version 5.0.51a, PHP version 5.2.17) and it works perfectly there. But I would like to run it in my hosting (cpanel,mysql version 5.1.68 and PHP version 5.3.23)

    I have already contacted my Hosting provider but the were not much help, just suggested me to check the connection parameters.

    Has anyone a clue of what is going wrong or what should I do?

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘"Error establishing database connection" but script says "connection successful"’ is closed to new replies.
Skip to toolbar