Are you using the latest version of DBI? Also, your "if ($dbh) {" seems a
little backward. According to the DBI docs, "If the connect fails (see
below) it returns undef and sets $DBI::err and $DBI::errstr." So shouldn't
your conditional be "if (!$dbh) {". Perhaps you are actually connecting.
I'm not sure why DBI::errstr would be defined in that case though. Also, I
hope that is not your real connection info (i.e. username, password,
hostname, database name). If it is, you should change it immediately.
Duncan
--
Duncan Salada | Titan | www.titan.com/validity
Email: [EMAIL PROTECTED] | Voice: 301-925-3222x375 | Fax: 301-925-3216
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 01, 2002 7:18 AM
> To: [EMAIL PROTECTED]
> Subject: Access denied for user: (from perl script)
>
>
> Hi, I have a problem accessing MySQL database. I have a
> database changes_db
> and when I access it with mysql -h jon -u join -p changes_db,
> I have no
> problems. But if I use Perl script to access same database I get:
>
> DBI->connect(database=changes;host=jon;port=) failed:
> Access denied for user: 'join@jon' to database 'changes_db' at
> ./test_db.cgi line 15
>
> The script is following:
>
> #!/usr/bin/perl -w
> use strict; # enforce declarations and quoting
> use DBI;
> use CGI qw(:all); # import shortcuts
> $| = 1; # disable buffering
>
> my $username = "join";
> my $password = "equant";
> my $database = "chances_db";
> my $driver = "mysql";
> my $port = '';
> my $hostname = "jon";
>
> my $dsn = "DBI:$driver:database=$database;host=$hostname;port=$port";
> my $dbh = DBI->connect($dsn, $username, $password);
>
> if ($dbh) {
> print $DBI::errstr;
> exit 1;
> }
>
> Regards
> Jon Ingason
> Sr Field Ops Eng
> IP/Router Operation
> Global One Services AB trading as Equant
> Solna strandv�g 82
> PO BOX 1
> 171 18 SOLNA
> SWEDEN
> --------------------------------
> Work: +46 8 5191 3316
> Fax: +46 8 5191 3200
> Cellular: +46 708 91 3316
> E-mail: [EMAIL PROTECTED]
> --------------------------------
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php