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

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

【perl】Connect to a MySQL using the Perl DBI module相关推荐

  1. 【Linux】【服务器】 CentOS7下安装MySQL(版本8.0)详细过程步骤

    一.检查是否安装过mysql [Linux][服务器]CentOS7下卸载MySQL详细过程步骤 二.下载Linux下的Mysql包,打开Mysql官网 1.MySQL官网 2.滑到最后,点击MySQ ...

  2. 【转】QT中使用MYSQL中文乱码解决方法

    [转]QT中使用MYSQL中文乱码解决方法 Linux下乱码解决办法: 1.在QT程序的main.cpp的main函数中添加红色字那三句: int main(int argc, char *argv[ ...

  3. 【数据库】(三)-- mysql 数据库操作应用

    [数据库](三)-- mysql 数据库操作应用 操作说明 使用 navicat 针对 mysql 进行 sql 的使用,mysql 运行在本地的 docker 环境的应用容器中. 语法和关键字什么的 ...

  4. 基于keepalived的mysql_【实用】基于keepalived的mysql双主高可用系统

    原标题:[实用]基于keepalived的mysql双主高可用系统 mysql单节点存储时,系统出现故障时服务不可用.不能及时恢复的问题,因此实际使用时,一般都会使用mysql双机方案,使用keepa ...

  5. kafka对接mysql_【Canal】利用canal实现mysql实时增量备份并对接kafka

    简介 canal 1.1.1版本之后, 默认支持将canal server接收到的binlog数据直接投递到MQ, 目前默认支持的MQ系统有: kafka: https://github.com/ap ...

  6. 【数据库】Ubuntu18.04安装MySQL详解

    00. 目录 文章目录 00. 目录 01. 安装MySQL 02. 配置MySQL 03. 查看MySQL状态 04. 配置远程访问MySQL 05. 问题分析 06. 附录 01. 安装MySQL ...

  7. 【转载】谁记录了mysql error log中的超长信息

    转载: https://www.cnblogs.com/DataArt/p/10260994.html [问题] 最近查看MySQL的error log文件时,发现有很多服务器的文件中有大量的如下日志 ...

  8. mysql 嵌入式 c开发环境_【Linux】嵌入式C语言MySQL编程(libmysqlclient-dev使用)

    文章目录 准备工作 相关函数解释 C变量类型 C语言常用开发接口 mysql_init mysql_real_connect mysql_query mysql_store_result mysql_ ...

  9. 【Linux】一步一步学Linux——perl命令(264)

    00. 目录 文章目录 00. 目录 01. 命令概述 02. 命令格式 03. 常用选项 04. 参考示例 05. 附录 01. 命令概述 perl命令是perl语言解释器,负责解释执行perl语言 ...

最新文章

  1. tlb存的什么_什么是MMU,TLB
  2. 进阶SQL技巧:subquery, string function, window function
  3. DPKG命令与软件安装、APT
  4. AI公开课:19.05.16漆远-蚂蚁金服集团CF《金融智能的深度与温度》课堂笔记以及个人感悟—191017再次更新
  5. 将ojdbc 添加到maven
  6. HTML示例04---文字
  7. Annotation Processing Tool
  8. 第7章--基本统计分析
  9. ng bind html br,使用PrimeNG开发angular web项目
  10. html js注册表单代码,用户注册常用javascript代码
  11. Excel数据分析案例二——预测销售额
  12. 监狱视频探视(会见)系统
  13. 昂达 v891 v1 终于 删除 windows 分区 并且恢复了容量。
  14. 远程时无法打开Internet站点
  15. 开源的高性能Java集合:GNU Trove介绍
  16. 【整理】Android-Recovery Mode(recover模式详解)
  17. Oracle数据库练习题(1)
  18. 【拔刀吧 TensorFlow】TensorFlow学习笔记八——何为卷积神经网络
  19. 进化树构建之邻接法(Neighbor-Joining)的介绍
  20. 自组网灵活补盲|北峰油气田勘测解决方案

热门文章

  1. 一、vi/vim编辑器
  2. 小程序,修改数组或对象中的值,通过input动态修改数组对象中的值
  3. 955. 删列造序 II
  4. Java自动计算迷宫正确路线算法源码
  5. 全网最细Docker安装Minio,填满最新版大坑(强烈推荐收藏)
  6. 深和jsonp【转】 jsonpk跨域问题详解
  7. MVVM  MVVM是Model-View-ViewModel的简写
  8. Asp.net生成工作流、审批流的解决方案
  9. 网站开发技巧参考大全 event js
  10. Google谷歌通过地址计算两地距离 HOW TO CALCULATE DRIVING DISTANCE BETWEEN 2 LOCATIONS