Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Restoring a mysql database from sql file

Options
  • 15-12-2011 5:46pm
    #1
    Registered Users Posts: 3,135 ✭✭✭


    Hi,

    This might be in the wrong forum. Long and short of my problem:

    I'm moving a wordpress website for my friend, it's hosted one server A and needs to be hosted on server B.

    Unfortunately his access to host A has expired so I had to contact their support team to get a backup of the files/databases etc.

    Now, they sent me a .sql file and a .create file. I've tried restoring the mysql database using phpmyadmin and the .sql file and it seems to import correctly.

    I'm just having an issue pointing wordpress to the sql database using the config file in the WP directory, it just won't link up. 'Error establishing a connection to the database'.

    I've tried a few things from googling this error but haven't had any luck. Has anyone done something similar recently and might be able to offer some assistance? Also I've checked the blog url and site url in the sql table are correct.


Comments

  • Registered Users Posts: 2,426 ✭✭✭ressem


    Are server A and Server B with different service providers? are they both linux?

    Have you created the new database users, probably in the hosting company's control panel?

    Also, depending on the company, the new users may have their name prefixed with the name of the database server, so this would have to be corrected /added in the wordpress config file.


  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    Tried confirming the DB_HOST is correct? The new server might not be happy using localhost (if it's set to that), I know godaddy uses another address.
    You could try a fresh wordpress install on the new server and see what the wp-config & general landscape looks like, then see where the differences are.
    And as ressem said, the table prefix and users.


  • Registered Users Posts: 3,135 ✭✭✭fifth


    ressem wrote: »
    Are server A and Server B with different service providers? are they both linux?

    Have you created the new database users, probably in the hosting company's control panel?

    Also, depending on the company, the new users may have their name prefixed with the name of the database server, so this would have to be corrected /added in the wordpress config file.

    Hi, yeah they're both on different hosts sorry. Yes both linux.

    Yeah I have, it won't allow me to create the exact same database name and users because there are too many characters apparently. The new host seems to have a shorter limit with their naming convention.

    So I'm trying to create a new database, import the backup and then going to edit the wp-config file with the new database details. But I'm still getting a database error. "Error establishing a database connection"

    @donkeystyle i'm running a few other wordpress blogs on the same host (under different domains) and they use localhost so that's not the issue.

    I may try to install a new wordpress installation if I can't figure this out.


  • Registered Users Posts: 2,426 ✭✭✭ressem


    When you connect to myPhpadmin, the home page should list the username, databasename and servername.

    Can you try with these versions of the settings (e.g. an ip rather than the database internal hostname?)


  • Registered Users Posts: 3,135 ✭✭✭fifth


    Managed to fix it.

    Installed a clean wordpress manually and just edited wp-config.php again but it worked this time. Having some problems with file attachments not displaying but it's not a big deal.

    Thanks for all the help.


  • Advertisement
  • Registered Users Posts: 1,657 ✭✭✭komodosp


    I don't think importing the SQL database from the SQL file will import the users / grants on it as well. If you didn't create the user that wordpress is using on the new database, then that would have thrown that error.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    komodosp wrote: »
    I don't think importing the SQL database from the SQL file will import the users / grants on it as well.
    It can and really depends on what (s)he was given in the SQL and CREATE files that were supplied.

    I think the OP's problem was that the config and management of MySQL differs between hosts, leading to a situation whereby (s)he's not been able to recreate the exact same schema and user names.

    This means that (s)he had to create the database schema using new names and users, which in turn meant that his/her original Wordpress code (that would have had the old names hard-coded) had to be edited accordingly.
    funkyflea wrote: »
    Having some problems with file attachments not displaying but it's not a big deal.
    Off the top of my head: Look at your directory write permissions.


  • Registered Users Posts: 3,135 ✭✭✭fifth


    It can and really depends on what (s)he was given in the SQL and CREATE files that were supplied.

    I think the OP's problem was that the config and management of MySQL differs between hosts, leading to a situation whereby (s)he's not been able to recreate the exact same schema and user names.

    This means that (s)he had to create the database schema using new names and users, which in turn meant that his/her original Wordpress code (that would have had the old names hard-coded) had to be edited accordingly.

    Off the top of my head: Look at your directory write permissions.

    Right on both counts - the users were restored to wordpress just the way they were before and it was the write permissions that was causing the attachment problem. Many thanks!


Advertisement