Have you tried changing the source port to e.g. 3307 so you avoid the
conflict with your localhost MySQL port?
Sonoma County Library
[log in to unmask]
707 545-0831 x581
>>> [log in to unmask] 06/25/08 05:59AM >>>
Is there anyway to support SSH tunneling through a MySQL DSN?
I would like to open a database connection to remote host through
Perl's DBI. The remote database is MySQL, but the server hosting the
database does not allow outside connections. Instead the systems
administrators suggest first setting up a local SSH tunnel, and then
making connections to the host. Something this:
$ ssh -T -L 3306:mysql.example.org:3306 [log in to unmask]
$ mysql -h mysql.example.org
Alas, this option does not work for two reasons. First, I get prompted
for my username after the first command and my shell crashes. Second,
and more importantly, port 3306 is already in use on my local machine.
The whole thing seems weird anyway.
Maybe I can configure tunneling in the DBD::mysql DSN? I see that
DBD::mysql supports SSH, but I see no tunneling option:
$database = 'foo';
$user = 'bar';
$password = 'baz';
$host = 'mysql.example.org';
$dsn = "DBI:mysql:database=$database;host=$host;mysql_ssl=1";
$dbh = DBI->connect( $dsn, $user, $password );
Am I missing something, or is there some trickery I can use with the
definition of $host and/or $database?
Eric Lease Morgan
Head, Digital Access and Information Architecture Department
Hesburgh Libraries, University of Notre Dame