简体   繁体   English

在@INC中找不到DBD / mysql.pm

[英]Can't locate DBD/mysql.pm in @INC

I have installed latest version of Perl from ActiveState version 5.18.2.1802 successfully. 我已经从ActiveState版本5.18.2.1802成功安装了最新版本的Perl。 I am using Mysql database at back end in windows 8 environment. 我在Windows 8环境中在后端使用Mysql数据库。 Wrote down the following code 写下以下代码

#!/usr/local/bin/perl
use CGI;
use DBI;

    $cgiObj = CGI->new;
    print $cgiObj->header('text/html');

    $params = 'DBI:mysql:world:localhost';
    $user = 'root';
    $pass = 'XXXXXX!';

    $conn = DBI->connect($params, $user, $pass);
    $sql='select * from city';
    $query =$conn->prepare($sql);
    $query->execute;

    while(@row=$query->fetchrow_array)
    {
        print "ID: $row[0], Name: $row[1]<br>\n";
    }

Please some one give me guidence 请有人给我指导

Presumably you haven't installed DBD::mysql. 大概您尚未安装DBD :: mysql。 But that assumes you have mistyped the error message (it would be "Can't locate DBD/mysql.pm", not "Can't locate DBD/Mysql.pm"). 但这假定您输入了错误消息(错误输入是“无法找到DBD / mysql.pm”,而不是“无法找到DBD / Mysql.pm”)。

You also aren't setting the DSN as documented; 您也没有按照文档所述设置DSN。 it should be in one of these forms: 它应采用以下形式之一:

$dsn = "DBI:mysql:$database";
$dsn = "DBI:mysql:database=$database;host=$hostname";
$dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";

Also, you will save yourself a lot of headaches in the future if you always say: 另外,如果您总是说:将来,您会为自己省去很多麻烦:

use 5.018;
use warnings;

in your scripts and properly declare your variables. 在脚本中并正确声明变量。 (Optionally use a lower minimum version number, but if you specify a version less than 5.012, you will need to also use strict; since that won't be done for you.) ((可选)使用较低的最低版本号,但是如果您指定的版本小于5.012,则还需要use strict;因为这不会为您完成。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 install_driver(mysql)失败:找不到DBD / mysql.pm - install_driver(mysql) failed: Can't locate DBD/mysql.pm Strawberry Perl / Eclipse / EPIC-在@INC中找不到MySql.pm(您可能需要安装MySql模块) - Strawberry Perl/Eclipse/EPIC - Can't locate MySql.pm in @INC (you may need to install the MySql module) 为什么我的Perl CGI抱怨“找不到Mysql.pm”? - Why does my Perl CGI complain “Can't locate Mysql.pm”? 在@INC中找不到Email / MIME.pm - Can't locate Email/MIME.pm in @INC DBD :: MySql初始化失败:使用生物信息学工具OrthoMCL时无法通过包“ DBD :: MySql”找到对象方法“ driver” - DBD::MySql initialisation failed: Can't locate object method “driver” via package “DBD::MySql” while using Bio-informatics tool OrthoMCL 如何在自定义@INC 中使用 DBI 构建 DBD::mysql? - How to build DBD::mysql with DBI in a custom @INC? Perl DBD无法在64位计算机上连接到MySQL - Perl DBD can't connect to MySQL on a 64-bit machine DBD:无法使用 HTTP 基本身份验证使用 MySql DB 加载驱动程序文件 apr_dbd_mysql.so - DBD: Can't load driver file apr_dbd_mysql.so with HTTP basic Auth usind MySql DB 错误“无法链接/包含 C 库 'zstd'”在 Mac Big Sur 上安装 DBD::mysql - MacPorts MySQL - error "Can't link/include C library 'zstd'" installing DBD::mysql on Mac Big Sur - MacPorts MySQL 试图安装Perl-Mysql DBD,无法找到mysql_config - Trying to install Perl-Mysql DBD, mysql_config can't be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM