Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Reading host from defaults file with DBD::mysql

by Llew_Llaw_Gyffes (Scribe)
on Jan 30, 2019 at 13:44 UTC ( [id://1229167]=note: print w/replies, xml ) Need Help??


in reply to Re: Reading host from defaults file with DBD::mysql
in thread Reading host from defaults file with DBD::mysql

Oh, I've traced through my code and I know that it's doing what it should and reading the correct section of the defaults file. The problem is that DBD::mysql does not appear to be passing along the host specification along with the username and password, and I'm wondering whether I have missed something in my usage. The documentation leads me to believe that it SHOULD be working, but it isn't.

  • Comment on Re^2: Reading host from defaults file with DBD::mysql

Replies are listed 'Best First'.
Re^3: Reading host from defaults file with DBD::mysql
by pryrt (Abbot) on Jan 30, 2019 at 14:57 UTC

    Have you gone through Basic debugging checklist? Sounds like you've now done part (using the debugger), but maybe not everything: Does your $opts{defaults} really contain what you think it does when it enters the sub you showed? If not, then the problem lies outside of what you've shown. If it does contain what you think it should, then give us a security-redacted version of $opt{defaults}, because we cannot debug your logic in that sub without knowing what's there. See also SSCCE, How to ask better questions using Test::More and sample data, and How do I change/delete my post?


    edit: add "everything": I had intended the "but maybe not: ..." to be one logical thought, separate from "you've now done part"... but when re-reading, it looked more like I was saying OP hadn't done even the running-the-debugger, which was not what I meant. sorry. /edit

      Actually, I think I've identified the problem. It appears it is working as long as there are NO SPACES in the setting lines in the MySQL defaults file. If there are spaces around the "=", the setting is not read.

      So a defaults file containing:

      [mysql] user=fred host=mydb.localdomain password=BANANA

      works, but:

      [mysql] user = fred host = mydb.localdomain password = BANANA

      does not.

        What module did you use for reading/parsing your INI file? Config::Tiny? Config::Simple? Config::INI? Something else? Or did you roll your own?

        For example, Config::Tiny handles spaces around the equals just fine:

        #!/usr/bin/perl -l use warnings; use strict; use Config::Tiny; my $ini_string = <<"EOINI"; a=nospace b = space [GROUP1] c=nospace d = space EOINI my $cfg = Config::Tiny->read_string($ini_string); use Data::Dumper; $Data::Dumper::Indent = 0; print Dumper $cfg; __END__ __OUTPUT__ $VAR1 = bless( {'_' => {'a' => 'nospace','b' => 'space'},'GROUP1' => { +'d' => 'space','c' => 'nospace'}}, 'Config::Tiny' );

        I don't have the other two installed, but Config::INI claims to handle spaces around the equals, and Config::Simple's claim of "whitespace support" implies to me that it might

        Seriously? Are you sure you had not changed anything other than spaces around "=" in the mysql defaults file?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1229167]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-19 19:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found