Re-Import the Database Tables for NextGen When Moving WordPress to a New Domain

How to re-import database tables for the NextGen Gallery Plugin when moving your WordPress website to a new domain – so your photo galleries work again!

hoar iceSometimes a website’s content needs to be moved to a new domain. If there are pictures and plugins involved, the process gets a little more complicated. I wanted to move a blog with posts and photo galleries from one domain to a totally different subdomain. There are really good instructions on what to do when moving your WordPress website to a new domain, and instead of rewriting them, there are links below.

How to Move WordPress to a New Domain
How to Move a WordPress Blog or Website

The keys to getting the NextGen Galleries back in working order on a different domain depends on being able to find and download the files that contain information about the previous NextGen database files in phpMyAdmin, then modifying and uploading them to the new domain’s server.

As I imported the xml file along with the whole wp-content folder (so the plugins were also replicated) onto the new – different server, I beamed with premature satisfaction that things seemed to be working. Then, with horror, I realized that the Nextgen photo galleries weren’t loading on the new site. (The Nextgen Gallery is a really great plugin for WordPress that allows uploading and organization for photos, among other things.)

I knew that the photos from the old site were in the new website and that all the previously used plugins had been reinstalled. This is because as the previous wp-content folder was being uploaded to the new server via ftp, I saw the photo names from the Nextgen Gallery uploading. (Downloading and uploading with compression took over one hour. I’m not complaining. Overall, it saved a lot of time.)

While I took care to replicate the posts, content and plugins, the galleries were not being accessed and could not be found. So, not wanting to upload over 100 photos and type all the photo details again, I started searching for a way to make this happen. The best explanation that I found was at the WordPress forums, but here are points of clarification.

Here’s a step by step way to get the Nextgen Galleries plugin working by going into phpMyAdmin.

1.  Log into the old server to access phpMyAdmin. Click on the correct database to find the wp_ngg_album, wp_ngg_gallery, and wp_ngg_pictures files. (My example is a bit wonky because I think I was messing around and did two installs, so your table info will likely not have the wp1.)

Here’s a screenshot of what PHPMyAdmin export values I used. (I had additional editing because my files had (wp1_ngg…) – a number one after wp, so I changed them all to wp – even for all of the picture files, but in the end, it worked!)

2.  Export them one at a time by making sure that only the chosen one is highlighted (on my first try, by default, every file was highlighted) by looking over the export values, then click “Go” in the lower right hand corner of the page.  This will allow you to name the file and save it to your computer.   “Save as” a .txt file.

3.  After downloading the files to your computer (see above, and before importing them to the new domain) open the files in a text editor to make sure that the correct, updated database name is in the file. Most people will only need to make sure that the new (destination) domain’s database be switched from the old one.


4.  Now log into the new server’s PHPMyAdmin. (It’s assumed that WordPress has already been installed, so you’ve already created the new database, and the plugins have been added or replicated.)

5.  Delete the wp_ngg_album, wp_ngg_gallery, and wp_ngg_pictures files, and use the import function to import your .txt files from your computer. (I had to delete them before importing them, but that probably had to do with which boxes I left check marked on the initial export.)  This replicates the previous NextGen commands and tables so that all the previous photos and galleries can be accessed and display as before.

This worked for me. All the galleries were recognized and loaded just as in the previous domain. Hope that it works for you.  Many thanks to Alex Rabe (NextGen Photo Gallery plugin) and Kevin Sylvestre (Slimbox display plugin) for creating and sharing the plugins.

This entry was posted in Wordpress Tweaks and tagged , . Bookmark the permalink.

59 Responses to Re-Import the Database Tables for NextGen When Moving WordPress to a New Domain

  1. Keya Lea says:

    Hugh – Thanks for adding this info. Hopefully it helps those having issues.

  2. Man this article saved my bacon! Thanks for posting!

  3. Thank you for your kind help!

  4. Keya Lea says:

    You’re welcome! Glad that the post helped. Thanks for letting me know that it still works.

  5. Mia says:

    for some reason, importing the sql tables into the new database worked fine, but the nextgen admin panel is not seeing them and they aren’t showing on the pages on the new site (which I simply imported the pages from the previous wordpress install). Any ideas?

    I changed the database name in the exported files before the import and also double checked the table names and the prefixes happened to be the same in both databases for the ngg tables.

  6. Keya Lea says:

    Mia – The galleries are commonly not seen if there is a mistake in typing in the new database name. If it’s not pointed to the right destination, the image files will not show up in the next-gen galleries. If you’ve made sure that everything is correct, then also see Hugh’s comment about changing SSH to root and entering the commands in the wp-content directory. They have also been copied below:

    I had the same problem after moving a site this morning. I followed your steps but still my images would not show up. My solution was to SSH into the server as root, navigate to the wp-content directory and run the following commands:

    chown -R apache gallery

    chmod -R 766 gallery/

    This changes the ownership of the directory to apache and sets the permissions for the directory recursively to 766. I’m not sure or not if I could have skipped your steps exporting the gallery tables, I suspect not but I’m not sure.

  7. Jack says:

    I’m having the same issue as “elena”.

    I have been migrating my blog from a MySQL4 database to an updated MySQL5, and it seemed everything was going smoothly. I was able to copy my ngg tables over successfully, all the galleries, images and thumbnails showed up fine on the new blog.

    The problem is I can’t create any new galleries, or edit existing ones. For instance, if I create a new gallery, it seemingly goes through all the motions, no error messages, but once it refreshes the new gallery does not show up. Odd thing is, it will successfully create the folder for the gallery in wp-content/gallery/ but it does not acknowledge the gallery in the database. I’ve set permissions correctly in both the plugin and the gallery folder.

    I then tried adding a new image to an existing gallery folder via FTP to see if it would show up after hitting “Scan Folder for new images”. Nothing. While the existing image and thumbnail are acknowledged, the new image is not added to the gallery.

    Is there some setting in the PHP tables that I might need to change? Some permission or version conflict that would cause this? I am able to do everything else just fine with the blog, new posts, plugins, everything else works smoothly. Thanks for any help!

  8. Jack says:

    Ha, nevermind, got it working. I disabled the plugin then exported all the databases again just to be safe. Deleted them, then enabled the plugin again so that it would rebuild the databases from scratch. Then I went into the new databases and imported everything into the newly created ones, and now it can write new galleries again. Whew.

  9. Keya Lea says:

    Good to hear you got it working. Thanks for sharing your process and the steps that you took. :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>