使用activeperl在windows下学习perl,今天想用perl连接mysql。
1 安装模块
首先dos下输入ppm,自动会弹出一个图形化界面列出了所有模块,我想找模块名字包含mysql的,但是没找到,只看到dbi,安装之,写了测试程序运行报错:
install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains:
C:/Perl/site/lib C:/Perl/lib .) at (eval 5) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: CSV, DBM, ExampleP, File, Gofer, ODBC, Oracle, Proxy, SQLite,
Sponge.
at test.pl line 4
2 Google了一下,发现下面网页,http://forums.sixapart.com/lofiversion/index.php/t29943.html
看到一句In addition to DBI, you also need DBD::mysql,遂在dos下输入ppm install "DBD::mysql",安装开始启动并成功。然后运行测试程序,搞定。
骂一句,NND,我是觉得装的模块名字中怎么应该带个mysql字样吧,但是图形化界面中没有列出来,害得我折腾了几个小时。
另外CPAN上mysql模块的地址:
http://search.cpan.org/~capttofu/DBD-mysql-4.013/lib/DBD/mysql.pm
PS:cnblog的网站分类->编程语言中有python等,居然没有perl。