使用的软件版本
DBI-1.609.tar.gz
DBD-mysql-4.012.tar.gz
建议使用以上版本搭配,否则可能连接mysql错误
一、DBI的安装
wget
tar -zxvf DBI-1.609.tar.gz
cd DBI-1.609
perl Makefile.PL
make
make test
make install
二、DBD的安装
注意mysql的环境变量,若没有则用 添加/usr/local/mysql/bin到环境变量PATH中
PATH=/usr/local/mysql/bin:$PATH;
export PATH (mysql的安装路径根据实际情况填写)
wget
tar -zxvf DBD-mysql-4.012.tar.gz
cd DBD-mysql-4.012
perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config
make
make test
make install
三、其它可能发生的状况
如果运行某个调用MYSQL数据库的程序时出现如下系统提示:
install_driver(mysql)
failed: Can't load
'/usr/lib/perl5/site_perl/5.6.1/i386-linux/auto/DBD/mysql/mysql.so' for
module DBD::mysql:
/usr/lib/perl5/site_perl/5.6.1/i386-linux/auto/DBD/mysql/mysql.so:
undefined symbol: uncompress at
/usr/lib/perl5/5.6.1/i386-linux/DynaLoader.pm line 206. at (eval 2)
line 3
那么说明DBD::MYSQL未安装成功。
此时将/usr/local/mysql/include/mysql/*
复制到/usr/include/
同时将/usr/local/mysql/lib/mysql/*
复制到/usr/lib/(64位系统/usr/lib64/)
然后使用perl Makefile.PL设置环境,再进行后续的正常安装,就能正确连接到MYSQL数据库。
另解:
WINDOWNS下安装:
DBI-MY
SQL下载
安装过程:用ppm
ppm> install DBI
ppm> install DBD-MySQL
unix下安装:
perl安装的默认路径:
/usr/local/
apache/cgi-bin/
无须配置perl即可运行,必有
语句:
#!/usr/bin/perl
print "content-type:text/html","\n\n";
安装DBI
shell> perl -MCPAN -e shell
cpan> install DBI
cpan> install DBD::mysql
The DBD::mysql installation runs a number of tests. These tests require
being able to connect to the local MySQL server as the anonymous user
with no password. If you have removed anonymous accounts or assigned
them passwords, the tests fail. You can use force install DBD::mysql to
ignore the failed tests.
DBI requires the Data:
umper module. It may be installed; if not, you should install it before installing DBI.
It is also possible to download the module distributions in the form of compressed
tar archives and build the modules manually. For example, to unpack and build a DBI distribution, use a procedure such as this:
Unpack the distribution into the current directory:
shell> gunzip < DBI-VERSION.tar.gz | tar xvf -
This command creates a directory named DBI-VERSION.
Change location into the top-level directory of the unpacked distribution:
shell> cd DBI-VERSION
Build the distribution and compile everything:
shell> perl Makefile.PL
shell> make
shell> make test
shell> make install
The make test command is important because it verifies that the module
is working. Note that when you run that command during the DBD::mysql
installation to exercise the interface code, the MySQL server must be
running or the test fails.
或者直接用port安装:
shell >cd /usr/ports/databases/p5-DBI/
shell >make install
shell >/usr/ports/databases/p5-DBD-mysql/
shell >make install
由于mysql5和以前版本的算法不同,所以
update mysql.user set password = old_password('newpwd')
where host = 'localhost' and user = 'root';
然后flush priviledges;
阅读(2953) | 评论(0) | 转发(0) |