Search code examples
phing

How to deploy mysql database to server via ssh


I try to use Phing for deploying site to the server.

Command which should create database or make changes:

 <pdosqlexec url="mysql:host=${db.host}; dbname=${db.name}"
         userid="${db.user}"
         password="${db.pass}"
         src="${project.basedir}/deploy/mysqlbuiltscripts/create_database.sql"/>

It works good on local machine. But I need to make changes on server too. Main problem - I have access to server database via SSH only. Question - How can I execute this command via SSH tunnel?

P.S. I tried to use <ssh username="${username}" password="${password}" host="${host}" command="${myMysqlCommand}">, but it does not suit me because it does not write changes to Phing "changelog" table.


Solution

  • Are you using dbdeployTask? If you are generating a delta for the remote server, then your file should have the changelog present.

    If you don't have access to your remote server, you may need to do the dbdeploy work on the remote server directly or tunnel your requests through ssh.

    My dbdeploy steps are:

    1. Run phing -> dbdeploy task
    2. Get a delta sql
    3. With mysql, run the delta sql script on the remote server
    4. Enjoy