Support » Fixing WordPress » Moving site to new server: error establishing database connection.

  • Resolved awhite2


    I am moving my site to a completely different server with a different url. I’m using godaddy for linux hosting.

    I backed up my site and my database onto my harddrive.

    I changed my wordpress to my new url.

    I uploaded my old site into a subdirectory.

    I created a new database and uploaded my old database. (I also tried with a blank database and it did not work)

    I updated wp-config.php to match my new settings.

    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘redacted‘);

    /** MySQL database username */
    define(‘DB_USER’, ‘redacted‘);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘redacted‘);

    /** MySQL hostname */
    define(‘DB_HOST’, ‘redacted‘);

    /** Database Charset to use in creating database tables. */
    define(‘DB_CHARSET’, ‘utf8’);

    /** The Database Collate type. Don’t change this if in doubt. */
    define(‘DB_COLLATE’, ”);

    and I cannot get the database to connect. I’ve also tried changing hostname to the IP and localhost.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator kmessinger


    This is what you followed?

    Yes, also because this got a message from the moderator on another forum, this is not my real password and username. This database does not exist.

    But, yes I followed that. I’ve gotten it to work without uploading my database, due to a mispelling in subdirectory folders, but with a database it still doesn’t work.

    I’m now trying to repair the database.

    After repairing the database I am still getting this error.

    If DB_NAME, DB_USER, DB_PASSWORD and DB_HOST are correct, database connection error would not occur. Check your database, note down these info and make sure again that you have entered them correctly.

    I used this code: <?php

    $link = mysql_connect(‘local’, ‘name’, ‘password’);

    if (!$link) {

    die(‘Could not connect: ‘ . mysql_error());


    echo ‘Connected successfully’;



    to test that and it connected successfully.

    Moderator kmessinger


    If you get the “Error establishing a database connection”, then the username, password, or server is wrong in some way. Period. Nothing else can cause that.

    This not my real password and username. This database does not exist

    I redacted it anyway. Was serving no purpose.

    Thanks for your confidence but my information was correct. The problem was in the way that the database was backed up, and some of the tables did not have data.

    For those who have this problem, try to back up your database again while checking on mySQL “structure and data” again. this resolved the issue for me.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Moving site to new server: error establishing database connection.’ is closed to new replies.