DBI:mysql -> using .my.cnf

From: Dave Brown (dhbrown_at_hobbes.dhbrown.net)
Date: 04/17/04


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


Relevant Pages

  • Re: UPDATETEXT table_name
    ... my SP could be running on ANY database. ... UPDATETEXT command; database will default to the current database. ... You have to hardcode the tablename, just as you have to hardcode the ...
    (microsoft.public.sqlserver.mseq)
  • Re: how to determine if date is a Federal holiday
    ... get externally (database, config file, web site) ...
    (microsoft.public.dotnet.languages.csharp)
  • Restore database without providing a name??/
    ... database name in the restore command? ... but right now I hardcode the database name ... into the restore command. ... different names and I don't want to have to prompt the user to enter ...
    (microsoft.public.sqlserver.server)
  • Re: Need Help in QUERY
    ... database. ... So we can't Hardcode that in the QUERY. ... > - Anith ...
    (microsoft.public.sqlserver.programming)
  • Re: Need Help in QUERY
    ... database. ... So we can't Hardcode that in the QUERY. ... > - Anith ...
    (microsoft.public.sqlserver.programming)