Turnkey SSH tunnel for MySQL PHP access

Very useful examples at the Linux Journal:

http://www.linuxjournal.com/content/creating-secure-tunnels-ssh
and I finally found a connection specification that would work:
root@lamp ~# mysql -h localhost -P 3308 -u root -psomepassword vlmdatabase
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysq
ld.sock’ (2)
root@lamp ~# mysql -h localhost -P 3308 -u root -psomepassword vlmdatabase
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysq
ld.sock’ (2)
root@lamp ~# mysql -h 127.0.0.1 -P 3308 -u root -psomepassword vlmdatabase
The last one WORKS!!!!

// http://stackoverflow.com/questions/6390463/why-isnt-mysqli-connect-working-but-mysql-connect-is

$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, DB_PORT);

// MySQL php connection example

http://www.w3schools.com/php/php_mysql_connect.asp

http://stackoverflow.com/questions/1998297/ssh-check-if-a-tunnel-is-alive

 

 

// More useful URLs:

http://stackoverflow.com/questions/1998297/ssh-check-if-a-tunnel-is-alive

http://freddebostrom.wordpress.com/2009/04/10/ssh-tunnel-from-the-command-line/comment-page-1/

https://blog.rjmetrics.com/2009/01/06/php-mysql-and-ssh-tunneling-port-forwarding/

http://createmycomau.wordpress.com/2011/04/11/mysql-via-ssh-for-php/

http://www.ytechie.com/2008/05/set-up-a-windows-ssh-tunnel-in-10-minutes-or-less/

http://howto.ccs.neu.edu/howto/windows/ssh-port-tunneling-with-putty/

Leave a Reply

Your email address will not be published. Required fields are marked *