On Sat, 06 Aug 2005 23:19:55 -0800, Malcolm Dew-Jones wrote:
Jay Vollmer (jv******@visi.com) wrote:
: On Sat, 06 Aug 2005 21:28:00 -0800, Malcolm Dew-Jones wrote:
: > Jay Vollmer (jv******@visi.com) wrote:
: > : Hi everybody.
: >
: > : Can I use DBI to interface Perl with mysqld running locally rather than
: > : with a 'true' MySQL server?
: >
: > : If not DBI, how can I do this?
: > If you have a mysql database installed and the mysql processes running on
: > your local computer then your local computer is the mysql server.
: >
: > In that case you can use DBI (with perl) to access the database. Just use
: > "localhost" as the server name.
"it doesn't work." is not a good enough description. Many things could be
wrong. At a minimum you need to tell us the exact error message and error
code, and also show us a minimal script that doesn't work.
Here is an example of the code:
#!/usr/bin/perl
use DBI;
$drh = DBI->install_driver( 'mysql' );
$dbh = DBI->connect("DBI:mysql:test:", 'username', 'password');
die "Cannot connect: $D: $DBI::errstr\n" unless $dbh;
$sth = $dbh->prepare("select * from test;");
$sth->execute;
while (($first_name, $field1, $field2, $field3) = $sth->fetchrow)
{
#Do something here;
}
I get the following error:
DBI connect('test:localhost','jvollmer',...) failed: Access denied for
user:
'jvollmer@localhost' (Using password: YES) at ./testsql.pl line 4
Cannot connect: : Access denied for user: 'jvollmer@localhost' (Using
password: YES)
But I have no trouble accessing the database using the mysql client.
Okay, that's the exaple and the error. I fixed it by removing the
servername, login and password entirely. It works if I do this:
$dbh = DBI->connect("DBI:mysql:test:");
Thanks for your time anyway.
--
JAY VOLLMER
JV******@VISI.COM