J
Jonas Andersson
Hi
I run Apache and collect info from my local MySQL database through a
Perl-CGI using DBI. Works fine. However, when I try to write a non-CGI
script (hence not using Apache) to access MySQL, I cannot connect to
the database.
I use
my $username="user2"; my $password="(not shown)";
my $data_source="DBI:mysql:MyDatabase:localhost";
$dbh = DBI->connect($data_source, $username, $password) or die "1";
which works fine when CGI:ed. But when I try this for my non-CGI
script, all I get is
DBI connect('MyDatabase:localhost','user2',...) failed: Access denied
for user: 'user2@localhost' to database 'MyDatabase' at newdeal1a.pl
line 165
error connecting
The username and password are obviously correct, and I can see that
this has got something to do with localhost, but I'm afraid I can't
see what. I have searched FAQs and the net, but I can't find any help.
I'd be most grateful for whatever input I can get for this - I'm sure
the problem is trivial.
Thanks a lot, JA
I run Apache and collect info from my local MySQL database through a
Perl-CGI using DBI. Works fine. However, when I try to write a non-CGI
script (hence not using Apache) to access MySQL, I cannot connect to
the database.
I use
my $username="user2"; my $password="(not shown)";
my $data_source="DBI:mysql:MyDatabase:localhost";
$dbh = DBI->connect($data_source, $username, $password) or die "1";
which works fine when CGI:ed. But when I try this for my non-CGI
script, all I get is
DBI connect('MyDatabase:localhost','user2',...) failed: Access denied
for user: 'user2@localhost' to database 'MyDatabase' at newdeal1a.pl
line 165
error connecting
The username and password are obviously correct, and I can see that
this has got something to do with localhost, but I'm afraid I can't
see what. I have searched FAQs and the net, but I can't find any help.
I'd be most grateful for whatever input I can get for this - I'm sure
the problem is trivial.
Thanks a lot, JA