-----Original Message-----
From: Doug Pisarek [mailto:dgp@stripped]
Sent: Friday, October 09, 2009 3:50 PM
To: perl@stripped
Subject: Mysql Perl Issue
Problem getting Perl to connect to mysql database. Here is all of the
information:
$ perl -v
This is perl, v5.8.4 built for sun4-solaris-64int (with 29 registered
patches, see perl -V for more detail)
Copyright 1987-2004, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the GNU General Public License, which may be found in the Perl 5
source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to
the Internet, point your browser at http://www.perl.com/, the Perl Home
Page.
mysql Ver 14.12 Distrib 5.0.51a, for sun-solaris2.10 (sparc) using
readline 5.0
------------------------------------------------------------------------
---------------------------------------------------
$ mysql -V
mysql Ver 14.12 Distrib 5.0.51a, for sun-solaris2.10 (sparc) using
readline 5.0
------------------------------------------------------------------------
----------------------------
Code running:
#!/usr/bin/perl
use DBI;
print <<END;
Content-type: text/html
<html>
<head>
<title>Example of Perl calling MySQL</title> </head>
<body bgcolor="white">
END
# database information
print"DB connect\n";
$db="c3c_v8_24_dev";
$host="db110g";
$userid="root";
$passwd="strata";
$connectionInfo="dbi:mysql:$db;$host";
# make connection to database
print"Make connection \n";
$dbh = DBI->connect($connectionInfo,$userid,$passwd) ||
die "Got error $DBI::errstr when connecting to $dsn\n";
# prepare and execute query
$query = "SELECT userid, user_name FROM ad_user"; $sth =
$dbh->prepare($query); $sth->execute();
# assign fields to variables
$sth->bind_columns(\$userid, \$user_name);
# output name list to the browser
print "Names in the people database:<p>\n"; print "<table>\n";$
./mysql_print.pl
Content-type: text/html
while($sth->fetch()) {
print "<tr><td>$userid<td>$user_name\n";
}
print "</table>\n";
print "</body>\n";
print "</html>\n";
$sth->finish();
# disconnect from database
$dbh->disconnect;
Error receiving:
$ ./mysql_print.pl
Content-type: text/html
<html>
<head>
<title>Example of Perl calling MySQL</title> </head>
<body bgcolor="white">
DB connect
Make connection
ld.so.1: perl: fatal: relocation error: file
/usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBD/mysql/mysql.so:
symbol mysql_init: referenced symbol not found Killed
<html>
<head>
<title>Example of Perl calling MySQL</title> </head>
<body bgcolor="white">
DB connect
Make connection
ld.so.1: perl: fatal: relocation error: file
/usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBD/mysql/mysql.so:
symbol mysql_init: referenced symbol not found Killed
Thanks,
Doug P.
| Thread |
|---|
| • FW: Mysql Perl Issue | Doug Pisarek | 9 Oct 2009 |