Neo's Blog

首頁 相本 討論 書籤

分類目錄
本站日誌 (51)
碎碎唸啦 (173)
網站架設 (84)
程式設計 (161)
軟體使用 (69)
電子商務 (126)
經營奇想 (48)
基金理財 (11)
聰明消費 (87)
電影心得 (47)
開放原碼 (16)
工作記錄 (2)
毛毛小記 (9)
就是不同 (2)




歷史資料
 




April 20, 2004
tarball 安裝 Perl DBI DBD::MySQL

Perl DBI 是一個讓 Perl 存取各種不同資料庫的套件,因為在 Linux 上使用 MySQL 的人也比較多,加上常見的 Blog 寫作軟體 Movable 也是採用 Perl ,習慣 MySQL 資料庫的使用者,也就必需裝上 DBD::MySQL 這個套件才能正常運作。

為什麼要採用 tarball 安裝呢? 我之前也有提過採用 perl -MCPAN -e"force install DBD::mysql" 線上安裝方法,但是在只有安裝 Perl 套件的情況下,這個指令是行不通的。

如果遇到這個狀況,就只好一個個手動加上去囉。

要安裝 DBD::MySQL,一定要先裝好 MySQL-Server 跟一組壓縮套件(libz-devel 、zlib-devel 都可以),如果是 RedHat 的最小安裝,您就必須安裝 zlib-devel,可至
http://www.gzip.org/zlib/ 下載,或是有 apt 的可以下 apt-get install zlib-devel 直接安裝。

另外要注意的是,安裝過程會用到 mysql_config 指令。所以用 tarball 安裝 MySQL 則可以正常運作,但如果 MySQL 是用 RPM 安裝,就要確定你有 mysql-devel 套件,沒裝的話可至 MySQL 的下載網頁下載您目前版本的「Libraries and header files」。

確定以上套件都有安裝,就可以到 http://search.cpan.org/dist/DBD-mysql 下載最新的 DBD-mysql 來安裝了。

# cd /usr/local/src
# tar -zxvf /root/DBD-mysql-2.9003.tar.gz
# cd DBD-mysql-2.9003
# export LANG=C 設定字元編碼,不然會出現一堆錯誤訊息
# perl Makefile.PL

請注意,因安裝程式預設是以「資料庫test」做連線測試,若MySQL有設帳號權限的話,必須在這裡指定一個測試資料庫讓安裝程式確定連線正常。

參數如下:
testdb 測試資料庫,預設為 test
testuser 連線使用者,預設為為空
testpassword 使用者密碼
testhost 資料庫位址,預設為 localhost
testport 資料庫 port

範例:
# perl Makefile.PL --testdb=資料庫 --testuser=使用者 --testpassword=密碼

這個動作只是做連線測試而已,並不會更動到資料庫。

再來 make 之後就完工了。

# make
# make test
# make install

官方安裝說明:
http://search.cpan.org/src/RUDY/DBD-mysql-2.9003/INSTALL.html

 
由 Neo 發表於 April 20, 2004 09:21 AM 收進你的MyShare個人書籤  

我在安装DBD::mysql的时候出现了以下错误,您看看知道怎么设置吗?
Can't exec "mysql_config": No such file or directory at Makefile.PL line 76.

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 465.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 465.
Can't exec "mysql_config": No such file or directory at Makefile.PL line 465.
Failed to determine directory of mysql.h. Use

perl Makefile.PL --cflags=-I

to set this directory. For details see the INSTALL.html file,
section "C Compiler flags" or type


上海网友 發表於 April 4, 2007 03:41 PM
發表迴響  
(*星號開頭為必填欄位)











(請輸入您看到的數字,看不到請按右鍵->顯示圖片)


記住我的資訊?







Copyright 2005 Neo's Blog All rights reserved.