I'm getting an "Access denied for user" error message when trying to connect to a MySQL database using DBI. I have no problem connecting with mysql -u borp -p $auth from command line, and the user borp has all privileges for borp.* I'm pretty stuck... The relevant bits of code:
Resolved. ><use strict; use warnings; use DBI; my $auth = &read_prompt("Authorize: "); $auth =~ s/\n//; ############## Added this to fix. my $output = &connect("show tables"); exit; sub read_prompt { my $message = $_[0]; print $message; system ("stty -echo"); my $out = <STDIN>; system ("stty echo"); print "\n"; return $out; } sub connect { my $query = $_[0]; my $dbh = DBI->connect('DBI:mysql:borp:localhost:3306' +,'borp',$auth) or die "Unable to connect to db: ".$DBI::errstr."\n"; my $sth = $dbh->prepare($query); my @result = (); $sth->execute(); if($query=~m/^select|^show|^desc/i){ @result = $sth->fetchrow_array(); } $sth->finish(); $dbh->disconnect; return \@result; }
In reply to MySQL with DBI: Access denied for user by sarpunk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |