實(shí)現(xiàn)perl連接MySQL數(shù)據(jù)庫(kù)的兩步驟
以下是對(duì)perl連接MySQL數(shù)據(jù)庫(kù)的實(shí)際操作步驟的介紹,其中包括如何正確的安裝模塊,CPAN上MySQL數(shù)據(jù)庫(kù)模塊的下載地址的介紹,以下的文章就是對(duì)這些內(nèi)容的描述,望你看完之后對(duì)對(duì)其有更深的印象。
使用activeperl在windows下學(xué)習(xí)perl,今天想用perl連接MySQL數(shù)據(jù)庫(kù)。
1 安裝模塊
首先dos下輸入ppm,自動(dòng)會(huì)彈出一個(gè)圖形化界面列出了所有模塊,我想找模塊名字包含MySQL的,但是沒(méi)找到,只看到dbi,安裝之,寫(xiě)了測(cè)試程序運(yùn)行報(bào)錯(cuò):
- 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了一下,發(fā)現(xiàn)下面網(wǎng)頁(yè),http://forums.sixapart.com/lofiversion/index.php/t29943.html
看到一句In addition to DBI, you also need DBD::MySQL,遂在dos下輸入ppm install "DBD::MySQL",安裝開(kāi)始啟動(dòng)并成功。然后運(yùn)行測(cè)試程序,搞定。
罵一句,NND,我是覺(jué)得裝的模塊名字中怎么應(yīng)該帶個(gè)MySQL字樣吧,但是圖形化界面中沒(méi)有列出來(lái),害得我折騰了幾個(gè)小時(shí)。
另外CPAN上MySQL模塊的地址:
http://search.cpan.org/~capttofu/DBD-MySQL-4.013/lib/DBD/MySQL.pm
PS:cnblog的網(wǎng)站分類->編程語(yǔ)言中有python等,居然沒(méi)有perl。
以上的相關(guān)內(nèi)容就是對(duì)perl連接MySQL數(shù)據(jù)庫(kù)的介紹,望你能有所收獲。
【編輯推薦】