快速业务通道

linux下perl连接mysql数据库环境部署详解

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-05-03
环境说明: 系统:red-hat Enterprise 5 数据库:mysql-5.1.35-linux-i686-glibc23二进制版 perl mysql驱动程序:DBD-mysql-4.011.tar.gz DBI: DBI-1.609.tar.gz perl版本 :5.8.8 要求:在red-hat上部署环境,perl可以对mysql数据库进行操作. 一、安装mysql数据库,这个是前提,perl的mysql驱动程序需要引用mysql/bin下的mysql_config文件. 解压mysql-5.1.35-linux-i686-glibc23.tar.gz 可以查看下INSTALL-BINARY文件.里面详述了安装的方法, 创建一个分组、便于数据库的用户管理 shell> groupadd mysql 添加用户
shell> useradd -g mysql mysql
shell> cd /usr/local
解压 shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
创建软连接 shell> ln -s full-path-to-mysql-VERSION-OS mysql
修改权限 shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql . 导入数据库初始化脚本
shell> scripts/mysql_install_db --user=mysql 设置数据文件权限
shell> chown -R root .
shell> chown -R mysql data 启动mysql
shell> bin/mysqld_safe --user=mysql & 你需要将你的mysql目录添加到环境变量PATH里 vi /etc/profile 在一行添加: PATH=$PATH:/usr/local/mysql export PATH 退出vi source /etc/profilemysql 配置完毕. 二、安装驱动程序 这个相对比较复杂,我安装的过程中一直报错,说"mysql.so"找不到,我搜了大量的论坛,也没找到解决方法,在mysql的官方网站这里找到了 http://dev.mysql.com/doc/refman/5.0/en/perl-support-problems.html

2.21.3. Problems Using the Perl DBI/DBD Interface If Perl reports that it cannot find the ../mysql/mysql.so module, the problem is probably that Perl cannot locate the libmysqlclient.so shared library. You should be able to fix this problem by one of the following methods:
  • Compile the DBD::mysql distribution with perl Makefile.PL -static -config rather than perl Makefile.PL.
  • Copy libmysqlclient.so to the directory where your other shared libraries are located (probably /usr/lib or /lib).
  • Modify the -L options used to compile DBD::mysql to reflect the actual location of libmysqlclient.so.
  • On Linux, you can add the path name of the directory where libmysqlclient.so is located to the /etc/ld.so.conf file.
  • Add the path name of the directory where libmysqlclient.so is located to the LD_RUN_PATH environment variable. Some systems use LD_LIBRARY_PATH instead.
第一步:我没执行成功,可能是版本问题 第二步:我使用 find / -name "libmysqlclient.so " 命令查找到了这个文件的路径 然后将其copy到 /usr/lib下 第三步:不需要做. 第四步:将 /usr/lib 添加到 /etc/ld.so.conf 文件的末尾 (事实上在这个系统里这句没有起作用,起作用的是下面这步) 第五步:LD_LIBRARY_PATH =$LD_LIBRARY_PATH :/usr/lib export LD_LIBRARY_PATH 现在你可以正确得安装你的驱动程序了: gzip -d DBD-mysql-4.011.tar.gz tar -xvf DBD-mysql-4.011.tar cd DBD-mysql-4.011 perl Makefile.PL make make test make install 搞定.
三:安装DBI gunzip < DBI-1.

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多
的内容动态改变的行高
  • linux下面修改默认的shell
  • Linux系统下通过Grub突破root用户的技巧
  • Flash as入门(7):创建影片剪辑
  • linux查看版本信息
  • Linux下的IDS入侵检测工具
  • 虚拟机下的linux与windows文件共享
  • RH253学习资料下载
  • 基于Tomcat5.0和Axis2开发Web Service代码详解 - 编程入门网
  • PhotoShop曲线给偏色照片校正色彩
  • Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

    地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

    电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

    《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号