A couple of points to note:
Note there is no connection info in the script at all. It's tucked away nicely in a cnf file. For example:my $my_cnf = 'path_to_somewhere_safe/my_cnf.cnf'; my $dsn = "DBI:mysql:;" . "mysql_read_default_file=$my_cnf"; my $dbh = DBI->connect( $dsn, undef, undef, {RaiseError => 1} ) or die "DBI::errstr: $DBI::errstr";
# my_cnf.cnf [client] host = hostname database = my_db user = my_usr password = my_pwd
The DBD::mysql docs give an indication on how to use option files but more can be found on the MySQL site:
To see which options are available:
The last link points out that you need the two undef parameters in the connect statement.
Version info:
MySQL -> 4.0.17 (remote)
MySQL -> 4.1.15 (local)
DBI 1.32 (remote)
DBI 1.49 (local)
DBD::MySQL 2.0419 (remote)
DBD::MySQL 3.0002 (local)
Hope this is of some use and many thanks to Your Mother for the pointer.
John
update:
The 'interesting article' linked to above should be credited to gmax (see below).
++ to gmax
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Keeping MySQL connection parameters in a safe place
by gmax (Abbot) on Dec 27, 2005 at 16:26 UTC | |
by dragonchild (Archbishop) on Dec 27, 2005 at 18:20 UTC | |
|
Re: Keeping MySQL connection parameters in a safe place
by leocharre (Priest) on Dec 27, 2005 at 19:22 UTC | |
by tirwhan (Abbot) on Dec 27, 2005 at 19:42 UTC | |
by leocharre (Priest) on Dec 28, 2005 at 15:25 UTC | |
by tirwhan (Abbot) on Dec 28, 2005 at 16:00 UTC |