This micro-tutorial is now continuously revised on runcommand.
Need to use WP-CLI on a WordPress site, but don’t have SSH access to its server? Simply change your local WordPress install’s database credentials to use the remote site’s configuration, such that the local WordPress install is using the remote database. You’re now free to run commands to your heart’s content.
Keep in mind:
- The remote WordPress site’s database will need to accept public connections, or you’ll need to be able to whitelist your IP address.
- Your local WordPress install should use the exact same codebase as the remote install.
- Any filesystem operations will be happening on your local machine, not the remote server. If you install and activate a plugin, the remote WordPress site will then try to run a plugin that doesn’t exist on its server.
- Bad things can happen. Be very careful.
But, I used this trick for data transformation on a Flywheel-hosted site earlier this week, and it worked like a charm.