1

I'm attempting to move toward developing WordPress sites locally, rather than on a live server, and as part of that move I'd like the ability to have a local and a remote version of a site, and easily deploy changes made locally the the remote site. That's easy enough for the filesystem changes using something like Git, but I'm not sure how to make database changes easy to transfer.

I understand that it's probably possible to write a script to somewhat automate this process, but I really don't know at all where to start.

1 Answer 1

1

Well, I think you've already alluded to the answer. You need to script your database changes. And then run that script on the live database using phpMyAdmin or something like this command if you have terminal access:

mysql db_name < scripted_changes.sql

If, however, you've referring to CONTENT changes then that's a different thing all together. eg If you edit a post on your dev site and want that post change to be applied to your live site, or if you've added and activated a plugin on your devsite. If this is what you want, I am sure there are solutions, but I would recommend you look at your workflow to see if this is necessary.

8
  • I realize I need to script those changes, but I don't have any experience doing that - I'm looking for suggestions on how to go about doing that (basically a high level overview - I'm not expecting anyone to write it out for me). Commented Dec 7, 2011 at 12:57
  • Would importing database changes not capture e.g. a new post made? And would that not capture e.g. a plugin activation if the filesystem changes were also deployed? Commented Dec 7, 2011 at 12:58
  • Scripting changes to your database STRUCTURE would be a set of SQL statements (eg ALTER TABLE). The problem with scripting changes to CONTENT, eg adding a post, is that you need to know ecxactly what changes to the database Wordpress is making and therefore not really practical. Further if you added a post to your dev site, say a post with ID 100. It might be that that post ID is already in the live site, so you can't simply script that as SQL.
    – user10617
    Commented Dec 7, 2011 at 13:12
  • Note: for moving posts between sites, you can always use Wordpress's export/import feature. Also, you might well be able to find plugins or online services to achieve what you want - I don't know.
    – user10617
    Commented Dec 7, 2011 at 13:15
  • Thanks, that clarifies things somewhat. What about scripting a one-time dump of the local DB and import into the remote DB (possibly to include overwriting any existing data in the remote DB)? That would at least allow for having a remote (internet-accessible) site to use for sharing/display purposes, and periodically pushing changes to it from a local site. Commented Dec 7, 2011 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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