Old Wordpress entries imported - a forgettable tech log
Techie Stuff May 16th, 2008For a few months this whole blog was down and only recently I just made a new blog here and posted new entries. Well I finally got the entries from the old blog out of the backed up database. What made the blog break? It was auto-installed by a tool at my domain called “Fantastico”, which kept nagging me to upgrade to the latest wordpress for security reasons. I think it was incompatibilities with the style that made everything completely dysfunctional after I upgraded. I couldn’t get it working with other templates either. I don’t know what the deal was. I couldn’t login to the blog admin; I couldn’t do anything. Totally baffling.
It would have been way simpler to use Wordpress’ export feature and just get all the entries in an .xml importable file. How did I get the old entries back from the database? show
It was a serious pain. Fortunately, though I didn’t have an .xml backup, I had a backup of the database before the blog broke - exported to a .sql file with instructions for re-creating and filling every table in the database - before I tried to upgrade the blog. If I hadn’t done that, I don’t know that the entries could have been extracted from the database of the broken blog. If I didn’t have a backup it might have all been permanently hosed. .. actually.. maybe I could have just exported the entries and comments tables from the database, and imported them to the database on a new install. Hmm. Maybe that would have worked and been simpler. Maybe not.. I’d need the categories from the database too, wherever they would be.. Anyway -
I first tried installing a new blog, then importing from the .sql export backup of the database. Problem: the file was about twelve flipping megabytes (why!? I still don’t know), and when I tried importing that .sql file into the new blog’s database via my host’s phpMyAdmin, it hung and refused to import. Apparently most hosts limit .sql imports to 2 megabytes.
So I tried becoming my own host. On my own Windows XP machine, I installed Apache 2.2, PHP 5.0 (which needed to be told that Apache’s configuration file is at C:\Program Files\Apache Software Foundation\Apache2.2\conf ), mySQL-whatever-the-latest-version-is (3?), and to make database manipulation of mySQL easier, phpMyAdmin (which uses PHP to automate mySQL database management). Shouldn’t I be making a few hundred thousand dollars somewhere for even knowing what these things are? No, because it took me forever to figure out how to do this (plus, it’s dreary awful boring, and God has given very special graces to anyone who can bear to do this kind of thing for a living). I’ve done it before. What could be so difficult? That all the interoperability of these three has changed since the versions I used a few years ago for reasons as forgettable as my now using them
I couldn’t find anything on the web about integrating all the current versions of these. Trying so many different ways to install them, I finally figured out that they all find and work with each other automatically if you install them in the proper order. First, Apache. Then mySQL. Then PHP, which (for phpMyAdmin) you should install with the mySQL, mcrypt, and Multi-Byte-String extensions (and if you want to import from compressed database exports, the zip and/or zlib filters?) Then phpMyAdmin, in which install you have to find the config.inc.php and put the root database user and password in controluser, user, controllpass, and password - maybe you have to give it some database names to create too, I don’t remember. That’s not the most secure way to do it - countroluser and controlpass ideally shouldn’t be the root user/pass, but a custom user/pass for phpMyAdmin.
By the way, to block anyone on your internet connection from accessing whatever you publish on your machine’s own Apache install (unless you want them to - to host internet web sites from your own machine, which you can do, but I don’t know what security issues that might raise), at a minimum put this in your Apache configuration file:
<Location />
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Location>
What that does is block all traffic except from your own computer, localhost, or 127.0.0.1 (you can navigate to the server on your own machine in a web browser by typing either localhost or http://127.0.0.1 )
Once I had all that working, I installed wordpress on my very own Windows machine’s server (this is one of those utterances only geeks make with breezy finesse, as if that in itself is so simple).
[Update: on a subsequent install of this on a Windows machine, Wordpress didn’t function if I had php indexing off in the Apache install. I have no idea why it didn’t complain about that on the previous install, but I fixed it (after googling the Apache error message I got + wordpress) by finding this line in Apache’s httpd.conf file -
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
- and changing it to this:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
.. end of update]
I then tried to import the .sql file backup of the database of my old install via phpMyAdmin (first I made an empty, new database to import to). It hung and refused to import the twelve megabyte file (just like at my web host - aaagh!), but directed me to documentation on the problem, recommending a script called BigDump which works in conjunction with phpMyAdmin, automatically breaking a very large .sql import into smaller chunks and submitting the chunks in steps. I got that script and the instructions were easy enough - give it the .sql file name, database user and password, create an upload directory in the phpMyAdmin install (and tell the phpMyAdmin config file about it - okay that’s less obvious), place the script and .sql file there and navigate to the import script), and it worked! According to something I read, I could have imported via the mySQL command line without a hitch on very large files, but for deeply ethical reasons (specifically, an obsessive compulsion to do things the easy way even if it’s harder), I am against looking up commands and entering them into a prompt, if I can avoid it. When I then went to my blog’s login (which in this case was http://127.0.0.1/open_hatch_backup/wp-admin/admin.php ), the blog was working, with the old entries right there! Except that.. all the entries redirected to this here very blog you are reading. I updated the config table in the database to make the blog URL at localhost. Then I was getting some entries directing properly to localhost, but not all. Whatever - I don’t need any of that. I could get to the export function in the blog admin, and I used that to get the .xml export of all the entries, comments etc. I wish I had begun with (the .xml file it exported was under 2 megabytes, in contrast to the 12 megabyte .sql database backup I started with). Once I had that file I logged into this here blog and used the import function, giving it that .xml file I’d exported. Snap! All the old blog entries and comments are back.
Except the image galleries that were relying on plugins and image directories and plugin database tables I haven’t copied from the old blog - those galleries are broken. No matter - I could fix them with the backups I have (the old blog is still in a backup folder at my host), but I’m going to redo all those galleries with something I like better, I think - simpleviewer, which I’m using at this entry at this other blog.
Wasn’t that painful?