Error connecting to database.... (7 posts)

  1. martingreenwood
    Posted 5 years ago #

    Hi all.

    I am literally banging my head against the wall with this problem:

    I moved my blog (garstangblog.co.uk) to a new server, moved all files, backed up database, imported old DB to new DB, changed wp-config.php and added new db name, password and local host.

    but i am still getting "error connecting to database"

    for love nor money can i figure this problem out...

    any help will be highly appreciated.

  2. calnorth
    Posted 5 years ago #


    Me also as of last night. Have had to email my Support Desk.. as usual. I use inmotionhosting in the US and they are normally quick to respond. Not this time though. I get the localhost problem everytime I setup a MySQL database.

  3. Saqib Khan
    Posted 5 years ago #


    Same problem here. My hosting provider ServerSea transferred two of my websites brandasy.com and restaurants-uncut.com to a new server of theirs as their earlier crashed.

    Although all files were moved and DB was imported by me, the dreaded 'error connecting to database' error.

    Can anyone help us?

    Also avoid ServerSea. Their service sucks!

  4. James Huff
    Volunteer Moderator
    Posted 5 years ago #

    saqib62, contact your hosting provider to confirm that the values entered into wp-config.php are correct. More than likely, the DB_HOST value is different on the new server.

  5. obscure
    Posted 5 years ago #

    but i am still getting "error connecting to database"

    Have you confirmed that the database username, password and hostname are correct by connecting to the database using phpMyAdmin?

  6. Saqib Khan
    Posted 5 years ago #

    Thanks James for the tip. No, the DB_host was the same.

    I have finally succeeded in getting Restaurants Uncut up and running.

    And here's how I did it. On the old server, I only had to write the database and username without any prefix. However, on the new server, both these terms needed to have the the domain as the prefix in the wp-config file.

    For example Martin would add these values garstangblog_database and garstangblog_username.

    However, for some inexplicable reason the same technique is not working on Brandasy.

    Here's the error when I try to access the /wp-admin:

    Can’t select database

    We were able to connect to the database server (which means your username and password is okay) but not able to select the brandasy_brand database.

    * Are you sure it exists?
    * Does the user brandasy_saqib have permission to use the brandasy_brand database?
    * On some systems the name of your database is prefixed with your username, so it would be like username_brandasy_brand. Could that be the problem?

    Now why did restaurants uncut work and brandasy didn't when I had used exactly the same technique on both?

    Any help would be greatly appreciated.

  7. esmi
    Forum Moderator
    Posted 5 years ago #

    Different hosting accounts manage, and name, their databases differently.

Topic Closed

This topic has been closed to new replies.

About this Topic