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.


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.

| improve this answer | |
  • 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). – Travis Northcutt Dec 7 '11 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? – Travis Northcutt Dec 7 '11 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. – ZweiBlumen Dec 7 '11 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. – ZweiBlumen Dec 7 '11 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. – Travis Northcutt Dec 7 '11 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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