WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Moving site to new server: error establishing database connection. (8 posts)

  1. awhite2
    Member
    Posted 10 months ago #

    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.

  2. kmessinger
    Volunteer Moderator
    Posted 10 months ago #

    This is what you followed?
    http://codex.wordpress.org/Moving_WordPress

  3. awhite2
    Member
    Posted 10 months ago #

    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.

  4. awhite2
    Member
    Posted 10 months ago #

    After repairing the database I am still getting this error.

  5. Krishna
    Volunteer Moderator
    Posted 10 months ago #

    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.

  6. awhite2
    Member
    Posted 10 months ago #

    I used this code: <?php

    $link = mysql_connect('local', 'name', 'password');

    if (!$link) {

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

    }

    echo 'Connected successfully';

    mysql_close($link);

    ?>

    to test that and it connected successfully.

  7. kmessinger
    Volunteer Moderator
    Posted 10 months ago #

    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.

  8. awhite2
    Member
    Posted 10 months ago #

    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.

Reply

You must log in to post.

About this Topic