Posts Tagged ‘Moving’

Moving a WordPress blog – some tips…

Tuesday, January 31st, 2012

Moving dayI just moved the blog to a new webhost today. From to
It took me quite a while to figure out the steps, as I haven’t worked with PHP/WordPress configuration files before. In case you want the bulletpoints, for moving your own blog, here they are:

You’ll need two things from the webhost you’re leaving:

- The complete contents of the FTP site (or minimum the wp-content folder)
- An export of the database (*.SQL)

I took a copy of everything in the web-root of the host I was leaving, cleared the contents of the host I was moving to (after backing it up, just in case ;-)), and then uploaded everything to the new host.
Servage had a webinterface where I could export the existing blog’s database as a *.SQL file, which I did.

After that I logged on to the phpMyAdmin website of UnoEuro and chose the SQL file for upload.

After that I figured that everything would be well – but alas I got the following message:

“Error establishing a database connection”

After Googling a bit I found out that the database settings are stored in the wp-config.php file. I figured out that since I had overwritten this with the Servage settings, the blog had a hard time connecting :).
So I deleted everything in the root folder of the FTP site again, and restored the backup I had, so the empty blog was in place. Then I deleted the wp-content folder, and uploaded mine. Among other things this folder has the plugins folder (where the syntax highlighter resides among others) and the themes folder where my custom theme is. So this folder is important for both the presentation and the functionality of the blog ;-).

Finding the right tables

After a bit of checking around in the config file, I noticed a variable called $table_prefix with the value drupalwp_.

* WordPress Database Table prefix.
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
$table_prefix = 'aiwp_';

I had noticed in the phpMyAdmin that there were quite a few tables beginning with this name. Why the 'Drupal' I shall never know, but it got me worried that I had chosen some wrong settings when setting up the blog using the 1-click interface at UnoEuro ;-). Then I noticed that there were two sets of identical tables: one set prefixed with aiwp_ and one set prefixed with drupalwp_. Then it dawned on me: The old webhost had a prefix of aiwp_. And after configuring the $table_prefix value I suddenly had a site which worked !  … almost :).

Where’s the last half of each post?

To my great horror I noticed that a lot of my posts only contained the first sentence. The rest was missing. And also – the layout was skewed … a lot. After digging throught the aiwp_posts, where the blogposts are, and looking at the backup.sql file I could see that right where the sentences had been snipped – were some linebreak tags:  \r\n. After thinking for a while I figured out that the encoding of the SQL file may have had something to do with it. So after editing the SQL file in UltraEdit, and saving as UTF-8, deleting all tables in the database and importing the SQL file again – voilá. The blog was functional :).
Here is the SQL of my first blogpost, with the \r\n as you can see:

 INSERT INTO `aiwp_posts` VALUES (7,1,'2009-10-23 07:30:52','2009-10-23 06:30:52','Hi everybody. Well I finally took the dive into the binary fray of the Blog-O-sphere and here it is. A blog about my passion \"Gamedevelopment\".\r\n\r\nIn the times to come I will be creating a site with tutorials meant for beginners to get up-and-running, while posting API ideas,tools, etc. of my own creation.\r\n\r\nLooking very much forward to getting started, sharing and reading your feedback.\r\n\r\n- Jakob \"XnaFan\" Lund Krarup','Off to a running start... :)',0,' A blog about my passion \"Gamedevelopment\".','publish','open','open','','off-to-a-running-start','','','2009-10-23 07:30:52','2009-10-23 06:30:52','',0,'',0,'post','',2);</p> 


I had a bit of cleanup, with some folders containing downloads. Since I am a unix newbie, I didn’t know that there is a difference in casing on *nix systems. So when I started using WordPress I had inadvertently  created a Downloads and a downloads folder which made it easy for me to make a mistake in uploading and linking to files. This was easy to fix, since all my blogposts were in the aiwp_posts table so I could use the REPLACE command in the phpMyAdmin to streamline.

UPDATE aiwp_posts
SET post_content = (REPLACE(post_content, ‘Downloads/’, ‘downloads/’));

After copying the files from Download into download,  I only have one download folder which is less frustrating ;-).

Hope some of you other WordPressers can use the info.