LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1777|回复: 7

安装perl与mysql连接数据库接出问题!高手请指点!

[复制链接]
发表于 2005-8-10 17:27:20 | 显示全部楼层 |阅读模式
:help  :help 安装DBI成功!.....也安装了DBD
访问CGI的页面的时候,出现这样的信息!
install_driver(mysql) failed: Can't load
  '/usr/lib/perl5/site_perl/i586-linux/auto/DBD/mysql/mysql.so'
  for module DBD::mysql: File not found at
  /usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166
什么问题呀????急呀!还是DBD没有安装成功!还是路径不对!
发表于 2005-8-11 09:15:19 | 显示全部楼层
没安装mysql的DBD驱动

http://dev.mysql.com/downloads/dbi.html
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-11 10:23:22 | 显示全部楼层
我已经安装了DBD啦!怎样测试成功!!DBD还没有装好!............
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-11 10:40:56 | 显示全部楼层
1.      perl Makefile.PL \
        --libs="-L/opt/mysql/lib/mysql -lmysqlclient -lz" \
        --cflags=-I/opt/mysql/include/mysql \
        --testhost=127.0.0.1
注:mysql安装路径/opt/mysql/
###提示信息!
Can't exec "mysql_config": No such file or directory at Makefile.PL line 79.

Cannot find the file 'mysql_config'! Your execution PATH doesn't seem
not contain the path to mysql_config. Resorting to guessed values!
Can't exec "mysql_config": No such file or directory at Makefile.PL line 467.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 467.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 467.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 467.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 467.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 467.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 467.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 467.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 467.
I will use the following settings for compiling and testing:

  cflags        (User's choice) = -I/opt/mysql/include/mysql
  embedded      (guessed      ) =
  libs          (User's choice) = -L/opt/mysql/lib/mysql -lmysqlclient -lz
  mysql_config  (guessed      ) = mysql_config
  nocatchstderr (default      ) = 0
  nofoundrows   (default      ) = 0
  ps-protocol   (default      ) = 1
  ssl           (guessed      ) = 0
  testdb        (default      ) = test
  testhost      (User's choice) = 127.0.0.1
  testpassword  (default      ) =
  testsocket    (default      ) =
  testuser      (default      ) =

To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.

Checking if your kit is complete...
Looks good
Using DBI 1.48 (for perl 5.008005 on i386-linux-thread-multi) installed in /usr/
lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI/
Writing Makefile for DBD::mysql

2.  make
###提示信息!
rm -f blib/arch/auto/DBD/mysql/mysql.so
/usr/bin/perl myld gcc  -shared -L/usr/local/lib dbdimp.o mysql.o  -o blib/arch/
auto/DBD/mysql/mysql.so   -L/opt/mysql/lib/mysql -lmysqlclient -lz
chmod 755 blib/arch/auto/DBD/mysql/mysql.so
cp mysql.bs blib/arch/auto/DBD/mysql/mysql.bs
chmod 644 blib/arch/auto/DBD/mysql/mysql.bs
Manifying blib/man3/DBD::mysql.3pm
Manifying blib/man3/DBD::mysql::INSTALL.3pm
Manifying blib/man3/Mysql.3pm
Manifying blib/man3/Bundle:BD::mysql.3pm

3.make test
###提示信息!

        Failed 68/68 tests, 0.00% okay
t/mysql2.............Had to create DBD::mysql::dr::imp_data_size unexpectedly at
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI.pm line 1167.
Use of uninitialized value in subroutine entry at /usr/lib/perl5/site_perl/5.8.5
/i386-linux-thread-multi/DBI.pm line 1167.
Can't locate object method "connect" via package "Mysql" at /tmp/software/DBD-my
sql-3.0002_1/blib/lib/Mysql.pm line 74.
t/mysql2.............dubious
        Test returned status 255 (wstat 65280, 0xff00)
Failed Test         Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/00base.t           255 65280     5    4  80.00%  4-5
t/10dsnlist.t        255 65280     3    6 200.00%  1-3
t/20createdrop.t     255 65280     5   10 200.00%  1-5
t/30insertfetch.t    255 65280    11   22 200.00%  1-11
t/35limit.t          255 65280   113  226 200.00%  1-113
t/40bindparam.t      255 65280    27   54 200.00%  1-27
t/40blobs.t          255 65280    11   22 200.00%  1-11
t/40listfields.t     255 65280    18   36 200.00%  1-18
t/40nulls.t          255 65280    11   22 200.00%  1-11
t/40numrows.t        255 65280    25   50 200.00%  1-25
t/41blobs_prepare.t  255 65280    24   48 200.00%  1-24
t/50chopblanks.t     255 65280    35   70 200.00%  1-35
t/50commit.t         255 65280    30   60 200.00%  1-30
t/ak-dbd.t           255 65280    90  180 200.00%  1-90
t/akmisc.t           255 65280   351  702 200.00%  1-351
t/dbdadmin.t         255 65280    21   42 200.00%  1-21
t/insertid.t         255 65280    12   24 200.00%  1-12
t/mysql.t            255 65280    68  136 200.00%  1-68
t/mysql2.t           255 65280    ??   ??       %  ??
1 test skipped.
Failed 19/20 test scripts, 5.00% okay. 857/860 subtests failed, 0.35% okay.
make: *** [test_dynamic] Error 255


4.make install
###提示信息!
[root@test DBD-mysql-3.0002_1]# make install
Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql
/mysql.so
Files found in blib/arch: installing files in blib/lib into architecture depende
nt library tree
Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Mysql.pm
Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/mysql.pm
Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/mysql/GetI
nfo.pm
Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Mysql/Statemen
t.pm
Installing /usr/share/man/man3/DBD::mysql.3pm
Installing /usr/share/man/man3/Mysql.3pm
Installing /usr/share/man/man3/DBD::mysql::INSTALL.3pm
Installing /usr/share/man/man3/Bundle:BD::mysql.3pm
Writing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/mysql/.p
acklist
Appending installation info to /usr/lib/perl5/5.8.5/i386-linux-thread-multi/perl
local.pod


我就是这样安装的!DBD有没有成功呀?
回复 支持 反对

使用道具 举报

发表于 2005-8-11 11:37:01 | 显示全部楼层
重新安装下mysql

从那个网站上下载最新版本
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-12 10:37:35 | 显示全部楼层
Post by luoyong
重新安装下mysql

从那个网站上下载最新版本


那里出问题啦???mysql可以正常使用!可以创建数据库!可读写数据?那里问题!
回复 支持 反对

使用道具 举报

发表于 2005-8-13 09:36:43 | 显示全部楼层
使用PERL要学会使用CPAN,不要动不动就使用源代码编译。另外你的语句是怎么写的?有没有在终端下测试?
我是不用mysql的,但是我用CPAN安装了一遍DBI和DBD::mysql,发现很简单,测试一次通过。过程简单介绍如下:
安装DBI
[php]
$>su
$>cpan
cpan>i /dbi/
cpan>get DBI
cpan>make DBI
cpan>test DBI
cpan>install DBI
[/php]
安装DBD::mysql
[php]
cpan>i /dbd::mysql/
cpan>get DBD::mysql
cpan>make DBD::mysql
cpan>test DBD::mysql
cpan>install DBD::mysql
[/php]
写如下测试脚本vi test.pl
[php]
#!/usr/bin/perl -w
use strict;
use DBI;
#定义数据库名称;
my $database_name = "test";
# 定DBI联接语句;
my $database ="dbi:mysql:dbname=$database_name";
#定义用户名、口令;
my $db_user = "xxxxxx";
my $db_password = "xxxxxx";
### 连接.
my $dbh=DBI->connect($database,$db_user,$db_password) or die "can't connect!";
if ($dbh)
{print "mysqlconnect ok!\n";
print "my $dbh->port();\n";
}
else
{print "mysqlconnect false!\n";
}
##$dbh=DBI->disconnect;
[/php]
测试
[php]
$>chmod 755 test.pl
$>./test.pl
mysqlconnect ok!
my DBI::db=HASH(0x81abd08)->port();
[/php]
测试成功。
另外你如果想知道你的DBD::mysql的安装路径,可以执行locate DBD::mysql来查找的。
回复 支持 反对

使用道具 举报

发表于 2005-9-14 18:53:46 | 显示全部楼层
那个错误并不是因为从源代码安装而引起的,因为我CPAN安装也出现了这个问题-_-b。

错误信息说Can't exec "mysql_config": No such file or directory at Makefile.PL line 79.
应该就是说没有找到mysql_config这个执行文件,而这个文件在/path/to/mysql/bin/下面。
所以只要$export PATH=$PATH:/path/to/mysql/bin 就可以了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表