Reputation: 61
I am trying to connect perl and mysql in a program but receive error: perl: symbol lookup error: /usr/local/lib/perl/5.10.1/auto/DBD/mysql/mysql.so: undefined symbol: mysql_init. Please guide..
I have installed mysql through xampp and run it using xampp (/opt... commands) on terminal. Mysql is running successfully from terminal, but i cannot retreive values through perl program.
Perl program i am running is:
#!/usr/bin/perl -w
use DBI;
$dbh = DBI->connect('dbi:mysql:first','root','shaifu')
or die "Connection Error: $DBI::errstr\n";
$sql = "select * from q";
$sth = $dbh->prepare($sql);
$sth->execute
or die "SQL Error: $DBI::errstr\n";
while (@row = $sth->fetchrow_array) {
print "@row\n";
}
where first is database and q is table.
Also DBI and DBD are installed as perl -e 'use DBI' and perl -e 'use DBD::mysql;' return nothing on terminal.
Please help me to solve the problem.
Upvotes: 1
Views: 3664
Reputation: 15121
Okay, I will cut off this inefficient information query process, and just guess what the problem is.
/usr/local/lib/perl/5.10.1/auto/DBD/mysql/mysql.so: undefined symbol: mysql_init
This means one of the libraries depended by auto/DBD/mysql/mysql.so
cannot find, so
ldd /usr/local/lib/perl/5.10.1/auto/DBD/mysql/mysql.so
will show something like
...
libmysqlclient.so.18 => not found
And this means loader cannot find libmysqlclient.so.18
. This could means
yum install community-mysql-libs
; export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/path/to/libmysqlclient
, suppose your libmysqlclient.so
is located under /path/to/libmysqlclient
. /sbin/ldconfig -n /path/to/libmysqlclient
as root to add /path/to/libmysqlclient
, which is the directory that includes your libmysqlclient.so*
, to the library search paths of your system. By the way, if it is possible, you should always install any software you need through the package manager of your Linux distribution, this could avoid almost all of these annoying dependency problem.
Upvotes: 0