views:

222

answers:

1

I'm about to design / develop a WordPress website for client that wants me to build the site on his server. I prefer to develop locally, and without lag time, but I'd like to find a middle ground that works for both of us.

I have transmit for FTP and know there is a way to synchronize a local folder with the server. Although, My concern with this is that while the .php, plugins, images, .css, .js will transfer in this way, the my SQL tables will not.

Is there a way to fully sync up a local WordPress directory with one hosted on an FTP server to keep mySQL tables with posts, plugin settings etc. in tact?

Thanks!

A: 

Two ways: periodically export your database at the client's host, import it at local, then change the domain and other URLs in the database locally with an sql query in phpmyadmin, as you won't be able to login to WP locally until you've changes the base site URLs.

UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

and then update posts:

UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');

Or: you can call a non-localhost MySQL server in wp-config to you can keep one copy of the database for host and local, as long as the target server is configured to accept outside connections. In wp-config.php:

define('DB_HOST', 'mysql.example.com');  or 
define('DB_HOST', 'mysql.example.com:4454');

You may also need to open ports on your local machine's firewall.

songdogtech
...I was looking for something more or less automated.
j-man86
My second solution - calling the remote MySQL server - is as "automated" as it gets.
songdogtech