DBI:mysql -> using .my.cnf
From: Dave Brown (dhbrown_at_hobbes.dhbrown.net)
Date: 04/17/04
- Next message: Bill Karwin: "Re: text files"
- Previous message: Ardhendu Nandan: "HELP ME-IPC"
- Next in thread: Dave Brown: "Re: DBI:mysql -> using .my.cnf"
- Reply: Dave Brown: "Re: DBI:mysql -> using .my.cnf"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 17 Apr 2004 15:38:43 GMT
I'm trying to connect to a database "ipp", and rather than hardcode the
password, I'm trying to have the .my.cnf file read. According to some
google-surfing, the following should work:
#!/usr/bin/perl -w
# connect only, using .my.cnf
use DBI;
my $dsn = "DBI:mysql:ipp;mysql_read_default_file=$ENV{HOME}/.my.cnf";
my $dbh = DBI->connect($dsn,undef,undef,{RaiseError => 1})
or die "$0: can't connect: $DBI::errstr\n";
$dbh->disconnect;
My .my.cnf file looks like:
[client]
password = secret
I can connect by simply executing "mysql ipp", but when I try to run
the above code, I get a Segmentation Fault.
I've tried several variations of the above, always same result.
(I'm running on Linux, perl 5.6.1, DBI-1.21, DBD-MySQL-1.2219.)
-- Dave Brown Austin, TX
- Next message: Bill Karwin: "Re: text files"
- Previous message: Ardhendu Nandan: "HELP ME-IPC"
- Next in thread: Dave Brown: "Re: DBI:mysql -> using .my.cnf"
- Reply: Dave Brown: "Re: DBI:mysql -> using .my.cnf"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|