http://www.perlmonks.org?node_id=1053491


in reply to Re: Using DB->connect for mysql db without password
in thread Using DB->connect for mysql db without password

I don't want to appear stupid... :D

My problem is that I'm creating a software that does some analysis based on the use of a MySQL database. Now, I installed this program on a machine where I seen that mysql can be accessed without any pwd and usr. So I was wondering: "what if the user didn't set these two parameters?".

I'm going crazy searching for an answer. I think now that this is not a possible situation with PERL DBI... is it true?

  • Comment on Re^2: Using DB->connect for mysql db without password

Replies are listed 'Best First'.
Re^3: Using DB->connect for mysql db without password
by Corion (Patriarch) on Sep 11, 2013 at 13:24 UTC

    Have you tried using undef or '' for the username and/or password?

      Yes, I tried. It didn't worked....
        Using '' (or undef) works for me
        #!perl use strict; use DBI; my $dbh = DBI->connect('DBI:mysql:test:localhost','','') or die $DBI::errstr; print $dbh->tables;
        poj
Re^3: Using DB->connect for mysql db without password
by moritz (Cardinal) on Sep 11, 2013 at 19:27 UTC

    What software are you using, exactly? You don't seem to call DBI->connect, but rather a connect method on a different object. What kind of object is it?

    Usually connecting to mysql without user name and without password only works if you don't specify a host name either (not even localhost), then local domain sockets are used, and the identity of the system user is used.