我不知道 why,在 Mac 安装 DBI::mysql 总会报错

我为了给 cgi-bin 添加 mysql-perl 数据库支持,也是够麻烦的

  1. make sure that mysql and mydql_config is in your PATH

也就是命令行 which mysqlwhich mysql_config 都可以得到路径

  1. edit mysql_config

sudo vi $(which mysql_config) 要修改几个地方,确保几处环境设置正确

  • line95: pkgincludedir='/Applications/XAMPP/xamppfiles/include'
  • line113: include="$include -I/usr/include/php/ext/mysqlnd"
  1. install DBD::mysql using XAMPP cpan

sudo /Applications/XAMPP/xamppfiles/bin/cpaninstall DBD::mysql

  1. test if success install

/Applications/XAMPP/xamppfiles/bin/perl -MDBD::mysql -e1

如果没有输出表示成功了


第一个依赖错误

Can't load '/Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
  Reason: image not found at /System/Library/Perl/5.18/darwin-thread-multi-2level/DynaLoader.pm line 194.
 at -e line 0.
Compilation failed in require.
BEGIN failed--compilation aborted.

  1. locate libmysqlclient

/Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib

/Applications/XAMPP/xamppfiles/lib/libmysqlclient.a

/Applications/XAMPP/xamppfiles/lib/libmysqlclient.dylib

/Applications/XAMPP/xamppfiles/lib/libmysqlclient_r.18.dylib

/Applications/XAMPP/xamppfiles/lib/libmysqlclient_r.a

/Applications/XAMPP/xamppfiles/lib/libmysqlclient_r.dylib

  1. build linkage

    sudo ln -s /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

    sudo ln -s /Applications/XAMPP/xamppfiles/lib/libmysqlclient.a /usr/lib/libmysqlclient.a

  2. check again

    /Applications/XAMPP/xamppfiles/bin/perl -MDBD::mysql -e1

  3. test online

  1 #!/usr/bin/perl
  2 
  3 use utf8;
  4 use v5.16;
  5 use warnings;
  6 use DBI;
  7 print "Content-type: text/plain; charset=utf-8\n\n";
  8 print "$_\n" for (DBI->available_drivers);
  9 # mysql SQLite File DBM are supported
 10 print "----------\nInstalled\n\n";
 11 my %ins = DBI->installed_drivers();
 12 print "$_\t$ins{$_}\n" foreach (sort keys %ins);
 13 
 14 my $mydbh = DBI->connect('DBI:mysql:test;host=localhost','root','imac@mysql') or die "connect failed";
 15 my $sth = $mydbh->prepare("select * from test;");
 16 $sth->execute();
 17 #$result = $sth->fetchrow_hashref();
 18 while( $result = $sth->fetchrow_hashref ){
 19         for (keys $result){
 20         print "$_\t$result->{$_}\n";
 21 }}
 22 $mydbh->disconnect();

how to make CGI-Perl to work with Apache

• edit /Applications/XAMPP/xamppfiles/etc/httpd.conf
375 <Directory "/Applications/XAMPP/xamppfiles/cgi-bin">
376     AllowOverride all
377     Options ExecCGI Includes Indexes
378     # +/- no need
379     #AddHandler cgi-script .cgi .pl .py .sh
380     Order deny,allow
381     Allow from all
382     Require all granted
383     # allow and require are must
384 </Directory>
- 419     AddHandler cgi-script .cgi .pl .py .sh
- sudo chmod -R 0755 /Applications/XAMPP/xamppfiles/cgi-bin
- restart apache

Install DBD::mysql for Perl in XAMPP in Mac , solving errors的更多相关文章

  1. Install MongoDB driver for PHP on XAMPP for Mac OSX

    试了不少方法,最后还是这个最有效. [转自:http://thatsimplecode.com/install-mongodb-driver-for-php-on-xampp-for-mac-osx] ...

  2. centos perl: symbol lookup error: /usr/local/lib64/perl5/auto/DBD/mysql/mysql.so: undefined symbol: mysql_init

    之前在安装天兔数据库监控工具lepus的时候,运行时一直报perl: symbol lookup error: /usr/local/lib64/perl5/auto/DBD/mysql/mysql. ...

  3. XAMPP Apache + MySQL + PHP + Perl

    XAMPP Apache + MySQL + PHP + Perl 什么是XAMPP? XAMPP是最流行的PHP开发环境 XAMPP是完全免费且易于安装的Apache发行版,其中包含MySQL.PH ...

  4. percona innobackupex 遇到 connect to MySQL server as DBD::mysql module is not installed 问题

    percona innobackupex connect to MySQL server as DBD::mysql module is not installed [root@mysql softw ...

  5. MySQL MHA /usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln301] install_driver(mysql) failed: Attempt to reload DBD/mysql.pm aborted

    在公司随便找3台测试机搭个MHA,下面这个问题折腾了三天,之前没遇到过,查了OS版本发现一致,可能是不同人弄的OS吧,知道是cpan的问题就是搞不定,郁闷...[root@test247 ~]# ma ...

  6. Failed to connect to MySQL server as DBD::mysql module is not installed 问题的解决

    部署PXC ,卸了旧的MySQL perl-DBD-MySQL-4.013-3.el6.x86_64 这个包已经安装了,innobackup时一直在报错: Failed to connect to M ...

  7. 如何处理错误消息Please install the gcc make perl packages

    如何处理这行错误消息? Please install the gcc make perl packages from your distribution. 执行命令行:yum install gcc ...

  8. 【错误】:MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

    错误:MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决 ...

  9. 【mysql报错】MySQL host is blocked because of many connection errors; 解决方法

    MySQL host is blocked because of many connection errors; 报错 环境 操作系统:Linux 数据库:mysql5.7.27 错误提示 jHost ...

随机推荐

  1. Linux版OpenVPN安装、配置教程(转)

    本文将以目前最新的openvpn-2.3.4.tar.gz(更新于2014-5-2,下载地址)为例来介绍如何在Linux系统中安装.配置及使用OpenVPN. 在这里,我们选用了一台预装CentOS ...

  2. ZooKeeper常见问题(转)

    这段时间来,也在和公司里的一些同学交流使用zk的心得,整理了一些常见的zookeeper问题.这个页面的目标是解答一些zk常见的使用问题,同时也让大家明确zk不能干什么.页面会一直更新. 客户端 1. ...

  3. 强制回收和IDisposable.Dispose方法

    如果某对象的 Dispose 方法被调用一次以上,则该对象必须忽略第一次调用后的所有调用. 如果对象的 Dispose 方法被多次调用,该对象一定不要引发异常. 除Dispose 之外的实例方法在资源 ...

  4. .Net Framework 4.5.2 on Windows 10

    I was using Visual Studio 2013 to create a new solution, could not select ".NET Framework 4.5.2 ...

  5. oracle pl sql 解锁表

    select   p.spid,a.serial#, c.object_name,b.session_id,b.oracle_username,b.os_user_name   from   v$pr ...

  6. Java基础之写文件——将素数写入文件中(PrimesToFile)

    控制台程序,计算素数.创建文件路径.写文件. import static java.lang.Math.ceil; import static java.lang.Math.sqrt; import ...

  7. PostgreSQL Replication之第十章 配置Slony(2)

    10.2 理解 Slony如何工作 在我们开始复制我们的第一个数据库之前,我们想深入Slony的架构.理解这是如何工作的是非常重要的,否则,将不可能以一种有用的和合理的方法使用这个软件.与事务日志流不 ...

  8. 获取网络IP地址

    IPHostEntry iphost = Dns.GetHostEntry(txtDNS.Text);//解析并返回IPHostEntry对象 foreach (IPAddress ip in iph ...

  9. 三台CentOS 5 Linux LVS 的DR 模式http负载均衡安装步骤

    Linux负载均衡软件LVS(概念篇) 一. LVS简介 LVS是Linux Virtual Server的简称,也就是Linux虚拟服务器, 是一个由章文嵩博士发起的自由软件项目,它的官方站点是ww ...

  10. struts2的处理流程_2015.01.05

    01:首先经过web.xml里面的拦截 StrutsPrepareAndExecuteFilter 02:然后struts2内置的一些拦截器或用户自定义拦截器 Interceptor 03:用户编写的 ...