Welcome to jaever.com/diary

Perl安装DBD::MySQL (Mac OS X 10.4.10)的烦恼

今天想尝试Perl链接Mysql数据库的操作,可DBD::mysql安装了N次就是不行,遇到的错误:

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 466.

可我添加了--mysql_config的路径,仍然不能成功,最后还是找到把mysql_config的路径直接添加到$PATH中,才安装OK!

<perl Makefile.Pl --testuser=root --testdb=test --testhost=localhost>

make

sudo make install

安装成功,下面进行测试:

#!/usr/bin/perl -w

use DBI;
use strict;
use warnings;

my $dsn = 'DBI:mysql:test:localhost';
my $db_user_name = 'root';
my $db_password = '';

my $dbh = DBI->connect($dsn, $db_user_name, $db_password);

print "$dbh" if "$dbh";

输出<DBI::db=HASH(0x504888)>

应该是DBI对象了,ok继续前进!

 

 

INFO: 2008-07-19 10:02:11 | purpen | digg | link

Copyright © 2008 Jaever. All rights reserved.

This Site looks and works best when viewed using browsers enabled with JavaScript 1.5 and CSS, such as Firefox 1+ or Safari 3+.