WordPress.org

Ready to get started?Download WordPress

Forums

"Error establishing database connection" but script says "connection successful" (7 posts)

  1. plauren
    Member
    Posted 12 months ago #

    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?

  2. Archie22is
    Member
    Posted 12 months ago #

    Hmm,

    It shouldn't be that difficult really, edit your WordPress (wp-config.php) with the correct settings (for you live server)

    /** The name of the database for WordPress */
    define('DB_NAME', 'your_database');
    
    /** MySQL database username */
    define('DB_USER', 'root');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'password');
    
    /** MySQL hostname */
    define('DB_HOST', 'yourlivehost');

    Edit you database (siteurl) & (home) - this could just be your problem.

  3. Krishna
    Volunteer Moderator
    Posted 12 months ago #

    Can you post your site URL?

  4. plauren
    Member
    Posted 12 months ago #

  5. Krishna
    Volunteer Moderator
    Posted 12 months ago #

  6. railpnrstatus
    Member
    Posted 11 months ago #

    I had found the solutions on the web...this can be happen because of so many reasons..you can check out the solutions below...

    http://www.webburr.com/wordpress/error-establishing-database-connection-wordpress/748

    http://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/

  7. Krishna
    Volunteer Moderator
    Posted 11 months ago #

    http://www.siteadvisor.com/sites/69.162.101.154
    Is this explained in the links above?

Reply

You must log in to post.

About this Topic