热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

【perl】ConnecttoaMySQLusingthePerlDBImodule

2019独角兽企业重金招聘Python工程师标准TheDBImoduleitselfdoesnothavetheabilitytocommunicatewithanyspec

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

The DBI module itself does not have the ability to communicate with any specific DBMS: for that it is necessary to install the appropriate back-end module, which in the case of MySQL is DBD::mysql.

On Debian-based systems (including Ubuntu) the package that provides this module is libdbd-mysql-perl:


apt-get install libdbd-mysql-perl and on Redhat-based systems it is perl-DBD-mysql :


yum install perl-DBD-mysql The connection to the database is opened using the function connect . It returns a connection handle, which is needed when making subsequent calls to the DBI module:

my $dbh = DBI->connect('dbi:mysql:database=finance;host=db.example.com','user','xyzzy',{AutoCommit=>1,RaiseError=>1,PrintError=>0});


#!/usr/bin/perluse DBI;my $dbh = DBI->connect('dbi:mysql:dbname=finance;host=db.example.com','user','xyzzy',{AutoCommit=>1,RaiseError=>1,PrintError=>0});
print "2+2=",$dbh->selectrow_array("SELECT 2+2"),"\n";

【error】Can't locate DBI.pm

Can't locate DBI.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at ./example.pl line 3.
BEGIN failed--compilation aborted at ./example.pl line 3.

could indicate that:

  • the DBI module (and therefore probably the DBD module) has not been installed, or
  • the module is not on the include path (@INC).

【Error】Can't locate DBD/mysql.pm

[windows]ppm install DBD::mysql (重新安装,要先删除已安装的) 

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at (eval 3) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge.at ./example.pl line 5

indicates that the DBI module has been successfully loaded, and that some DBD modules are available (listed on the penultimate line), but that the specific DBD module needed to access MySQL cannot be found. Possible explanations are that:

  • the required DBD module has not been installed (see above),
  • the module is not on the include path (see above, but unlikely if the DBI module was loaded), or
  • the name of the data source passed to DBI::connect was incorrect.

【Error】

install_driver(mysql) failed: Global symbol "$VERSION" requires explicit package name at /mtkoss/perl/5.14.2-ubuntu-12.04/x86_64/lib/site_perl/5.14.2/x86_64-linux-thread-multi/DBD/mysql.pm line 6.

Compilation failed in require at (eval 311) line 3.

【error】

DBD::mysql initialisation failed: Can't locate object method "driver" via package "DBD::mysql" at /mtkoss/perl/5.14.2-ubuntu-12.04/x86_64/lib/site_perl/5.14.2/x86_64-linux-thread-multi/DBI.pm line 821.
Perhaps the capitalisation of DBD 'mysql' isn't right. at /proj/srv_kereadmin/keyword_script/module/keyword_mysql.pm line 44.




转载于:https://my.oschina.net/u/347414/blog/416250


推荐阅读
  • 去掉空格的方法——Python工程师招聘标准与实践
    本文介绍了去掉空格的方法,并结合2019独角兽企业招聘Python工程师的标准与实践进行讨论。同时提供了一个转载链接,链接内容为更多相关信息。 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 本文讨论了在openwrt-17.01版本中,mt7628设备上初始化启动时eth0的mac地址总是随机生成的问题。每次随机生成的eth0的mac地址都会写到/sys/class/net/eth0/address目录下,而openwrt-17.01原版的SDK会根据随机生成的eth0的mac地址再生成eth0.1、eth0.2等,生成后的mac地址会保存在/etc/config/network下。 ... [详细]
  • 十大经典排序算法动图演示+Python实现
    本文介绍了十大经典排序算法的原理、演示和Python实现。排序算法分为内部排序和外部排序,常见的内部排序算法有插入排序、希尔排序、选择排序、冒泡排序、归并排序、快速排序、堆排序、基数排序等。文章还解释了时间复杂度和稳定性的概念,并提供了相关的名词解释。 ... [详细]
  • PHP函数实现分页含文本分页和数字分页【PHP】
    后端开发|php教程PHP,分页后端开发-php教程最近,在项目中要用到分页。分页功能是经常使用的一个功能,所以,对其以函数形式进行了封装。影视网源码带充值系统,vscode配置根 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • 从Oracle安全移植到国产达梦数据库的DBA实践与攻略
    随着我国对信息安全和自主可控技术的重视,国产数据库在党政机关、军队和大型央企等行业中得到了快速应用。本文介绍了如何降低从Oracle到国产达梦数据库的技术门槛,保障用户现有业务系统投资。具体包括分析待移植系统、确定移植对象、数据迁移、PL/SQL移植、校验移植结果以及应用系统的测试和优化等步骤。同时提供了移植攻略,包括待移植系统分析和准备移植环境的方法。通过本文的实践与攻略,DBA可以更好地完成Oracle安全移植到国产达梦数据库的工作。 ... [详细]
  • Postgresql备份和恢复的方法及命令行操作步骤
    本文介绍了使用Postgresql进行备份和恢复的方法及命令行操作步骤。通过使用pg_dump命令进行备份,pg_restore命令进行恢复,并设置-h localhost选项,可以完成数据的备份和恢复操作。此外,本文还提供了参考链接以获取更多详细信息。 ... [详细]
  • Ihaveapolynomial(generatedfromthecharacteristicpolynomialofamatrix)andIdliketosolve ... [详细]
  • MySQL多表数据库操作方法及子查询详解
    本文详细介绍了MySQL数据库的多表操作方法,包括增删改和单表查询,同时还解释了子查询的概念和用法。文章通过示例和步骤说明了如何进行数据的插入、删除和更新操作,以及如何执行单表查询和使用聚合函数进行统计。对于需要对MySQL数据库进行操作的读者来说,本文是一个非常实用的参考资料。 ... [详细]
  • 本文介绍了Java类的访问级别,包括public、private、protected和package-private,并重点解释了package-private的含义和作用。package-private表示类只能在其所在的包内可见,而不能被其他包的类访问。该文章还提到了其他访问级别的作用和范围,并对Java类的可见性进行了详细说明。 ... [详细]
  • Hello,Imaintainawebcluster,withDebiani386andDebianAMD64nodes(itwa ... [详细]
  • systemd-nspawn可以创建最轻量级的容器(ns的意思就是namespace),本文的实验平台是Ubuntu16.04,x86_64机器。本文的目的是:在Ubuntu中用syst ... [详细]
  • 如何将CentOS8转换为CentOSStream
    CentOS Stream是一个持续交付的Linux发行版,它在RHEL之前处于领先地位。它将具有滚动发布,即不断进行更改。CentOS将成为一个上游版本,它将具有测试补丁和更新。 ... [详细]
author-avatar
连政宪景琪雅婷
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有