Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a localhost site that I heard I can migrate the site by just copy and paste the whole site from local to host if I changed WordPress Address (URL) and Site Address (URL) to my current hosted site address and then upload it to the host. Now my hosting server's site after pasted with my local host site seem sql db is broken...it only shows: "Error establishing a database connection", Do you know how to fix it?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Read http://codex.wordpress.org/Moving_WordPress#When_Your_Domain_Name_or_URLs_Change

You've only moved the PHP files. That is only part of the process.

Migrating the databse would mean:

  1. Create a database, if there isn't one already
  2. Move the database from your local server to the remote one.
  3. Edit/alter key values in the database
    1. The same wp-config editing trick used here will get you much of the way but won't fix any URLs that are probably in the database.
  4. A plugin called Velvet Blues Update Urls is very good for sorting out broken URLs after a move.

That is the hard way, but your attachments are likely to survive. You could have trouble if the MySQL versions between you local install and your host are different.

The easier way is this.

  1. Create a database on the remote server.
  2. Allow WordPress to install itself just like you did when you initially created the local site.
  3. Use the WordPress exporter at Tools->Export to export everything from your local install
  4. On the remote install, Import what you just exported. You will need to install the WordPress importer plugin
  5. Import your posts
  6. A plugin called Velvet Blues Update Urls is very good for sorting out broken URLs after a move.

The benefit is that the database is clean and fitted to your new host. The drawback is this: While the importer will offer to download and install your attachments, it won't be able to do so from a "local" address.

While I have done and it does work, I prefer the latter, for what it is worth.

Caveat: I cannot swear that I've remembered everything you will need to do. Go through the Codex page very carefully before doing anything.

share|improve this answer
    
Thanks for the info, though I used another guys info, think you deserve it at least for all these writing lol –  Adam Feb 16 '13 at 0:14
    
Since you said you "just copy and paste the whole site" which is not easily done with databases (but possible if you are carefull) I concluded that you had not setup/imported your database at all. How did you move your database? –  s_ha_dum Feb 16 '13 at 0:29
    
I actaully did is just use the existing database by change properties in wp-config for database name, user, pw and such, but now its coming out error of : Parse error: syntax error, unexpected T_STRING in /home/content/73/8452373/html/mysite/wp-includes/category-template.php on line 1193 –  Adam Feb 16 '13 at 16:04
    
Ok, basically you did the non-GUI version of what I called the "easier way". Re-upload wp-includes. –  s_ha_dum Feb 16 '13 at 16:12
    
oh ok, I am gonna try it out! –  Adam Feb 16 '13 at 19:47
show 1 more comment

You have to open the wp-config.php, located in your WordPress root directory, and then modify the options

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'YourOnlineDatabaseScemaName');

/** MySQL database username */
define('DB_USER', 'YourDatabaseUserNameHere');

/** MySQL database password */
define('DB_PASSWORD', 'YourDatabasePasswork');

This will make the message to disapear. In order to get more information on WordPress migration read the http://codex.wordpress.org/Moving_WordPress#When_Your_Domain_Name_or_URLs_Change

share|improve this answer
    
Wish I could vote up for you (but not enough rep lol) even though I did not completely used your method but it somehow confirmed what I thought :) Thanks –  Adam Feb 16 '13 at 0:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.