in reply to Reading host from defaults file with DBD::mysql
outputs:#!/bin/env perl use warnings; use strict; use DBI; my $db = "****"; my $host = "****"; my $cfg_file = "/tmp/my.cnf"; my ($dsn, $dbh); print STDERR "Without host=\$host\n"; $dsn = "dbi:mysql:mysql_ssl=1;database=$db;mysql_read_default_file=$cf +g_file;mysql_read_default_group=test_group"; $dbh = DBI->connect($dsn); print STDERR "\nWith host=\$host\n"; $dsn = "dbi:mysql:mysql_ssl=1;database=$db;mysql_read_default_file=$cf +g_file;mysql_read_default_group=test_group;host=$host"; $dbh = DBI->connect($dsn); print "\$dbh = $dbh\n";
The /tmp/my.cnf looks like:Without host=$host DBI connect('mysql_ssl=1;database=****;mysql_read_default_file=/tmp/my +.cnf;mysql_read_default_group=test_group','',...) failed: Can't conne +ct to local MySQL server through socket '/var/run/mysql.sock' (2) at +/tmp/test_db.pl line 12. With host=$host $dbh = DBI::db=HASH(0xa00318a18)
[test_group] host=**** port=3306 database=**** user=**** password=**** no-auto-rehash ssl=1
Update: This is on a cygwin system with the latest cygwin based perl and associated modules. I just tried it on a linux system and it works without specifying host=$host
|
|---|