MySQL through SSH Tunnel?
Posted 10 April 2012 - 01:23 AM
ssh -f email@example.com -L 3306:mysql-server.com:3306 -N
Once tunel is opened, in main.php config file, for db host use localhost, and enter your mysql server username/password.
Posted 14 December 2012 - 04:47 AM
@Pakotski: Chances are that you cannot do that via PHP. Write a script for initd/systemd/upstart to take care of that.
Posted 14 December 2012 - 05:51 AM
For me it seems that this is not possible in the main.php config file? So where is the db component initialized?
In continuation to what already answered, while it is possible (with SSH keys and passwordless login...) you would not wish to setup and destroy SSH tunnel with each request since it takes relatively lots of time to establish this tunnel. A few seconds usually.
Its like you're actually digging up a tunnel from the web server to the MySQL server and you wouldn't want to destroy and build it again on each request.
Posted 14 December 2012 - 05:55 AM
Posted 14 December 2012 - 08:01 AM
If this tunnel is critical or important enough, be sure to check the availability of the tunnel. It can hung up sometimes.