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?
2 Answers
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:
- Create a database, if there isn't one already
- Move the database from your local server to the remote one.
- Edit/alter key values in the database
- 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.
- The same
- 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.
- Create a database on the remote server.
- Allow WordPress to install itself just like you did when you initially created the local site.
- Use the WordPress exporter at Tools->Export to export everything from your local install
- On the remote install, Import what you just exported. You will need to install the WordPress importer plugin
- Import your posts
- 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.
-
Thanks for the info, though I used another guys info, think you deserve it at least for all these writing lol– AdamCommented Feb 16, 2013 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_dumCommented Feb 16, 2013 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– AdamCommented Feb 16, 2013 at 16:04
-
Ok, basically you did the non-GUI version of what I called the "easier way". Re-upload
wp-includes
.– s_ha_dumCommented Feb 16, 2013 at 16:12 -
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
-
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– AdamCommented Feb 16, 2013 at 0:15