How can I (semi) automate a database export and import to a different location?

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.

Related posts

Leave a Reply

1 comment

  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.