- 我的机器:Linux RHEL 5.5.56(64 位)、Perl 5.8.8。 Postgres 不在这台机器上。但我可以 ping Postgres 机器没问题。我的机器显然可以从互联网上的 CPAN 安装 Perl 模块。
- 'uname -a' 返回:Linux xxx 2.6.18-371.8.1.el5PAE #1 SMP Fri Mar 28 06:00:03 EDT 2014 i686 i686 i386 GNU/Linux
- 其他机器有 Postgres 8.4。
- 我不熟悉安装和使用任何 DBI 模块。需要详细的初学者说明。
- 我有 root 权限访问我的 Linux 机器。
- 我认为 yum 报告我安装了“postgresql-libs.i386”。百胜安装| grep postgres` 返回:'已安装 postgresql-libs.i386 8.1.23-10.el5_10'
这是我需要的吗?这是在我的系统上。
lrwxrwxrwx 1 root root 12 May 1 20:05 /usr/lib/libpq.so.4 -> libpq.so.4.1*
-rwxr-xr-x 1 root root 130K Feb 27 07:36 /usr/lib/libpq.so.4.1*
目标:我想从另一台机器上的 Postgres 服务器获取数据。我已经有了数据库机器的数据库用户名、密码和 IP。
我使用 cpanm 安装 DBI 很好,没有错误。当我安装 DBD::Pg 时出现错误。 CPAN错误日志如下:
cpanm (App::cpanminus) 1.6941 on perl 5.008008 built for i386-linux-thread-multi
Work directory is /root/.cpanm/work/1405531191.27414
You have make /usr/bin/make
You have LWP 6.04
You have /bin/tar: tar (GNU tar) 1.15.1
You have /usr/bin/unzip
Searching DBD::Pg on cpanmetadb ...
--> Working on DBD::Pg
Fetching http://www.cpan.org/authors/id/T/TU/TURNSTEP/DBD-Pg-3.3.0.tar.gz
-> OK
Unpacking DBD-Pg-3.3.0.tar.gz
Entering DBD-Pg-3.3.0
Checking configure dependencies from META.yml
Checking if you have version 0 ... Yes (0.88)
Checking if you have DBI 1.614 ... Yes (1.631)
Configuring DBD-Pg-3.3.0
Running Makefile.PL
Path to pg_config?
No POSTGRES_HOME defined, cannot find automatically
Configuring DBD::Pg 3.3.0
-> N/A
-> FAIL Configure failed for DBD-Pg-3.3.0. See /root/.cpanm/work/1405531191.27414/build.log for details.
- 我是否可以从另一台机器上的 Postgres 数据库获取数据?
- 有没有人提供有关如何执行此操作的说明的链接?我已经在谷歌上搜索了一些东西,阅读了 CPAN、Stackoverflow 和 Perlmonks 上的东西,但没有结果。
- FAQ http://dbi.tiddlyspot.com/没有特定于安装 DBD::Pg 的信息。
- 如果我通过 yum 安装 Postgres,安装是否会覆盖任何文件,例如库?如果有,是哪些?我们确实有我们在这台机器上使用的其他应用程序。
如果我让它工作,我的第一步就是显示关于 DBI 驱动程序的非常基本的信息。下一步是在 SELECT 语句中显示一个表中的几个字段。
我不会返回数百万条记录,但返回 100 条记录肯定在大概范围内。
谢谢!
最佳答案
如果您使用已经为您的系统构建并可用的软件包,那么您将不会遇到任何这些问题。
$ sudo yum install perl-DBD-Pg
... Lots of output snipped ...
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
perl-DBD-Pg x86_64 1.49-4.el5_8 centos-update 115 k
Installing for dependencies:
postgresql-libs x86_64 8.1.23-6.el5_8 centos-update 197 k
Transaction Summary
================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 312 k
Is this ok [y/N]:
我的示例使用 Centos 5.8.8,但它在 RHEL 上应该也能正常工作。
关于linux - 我可以使用 Perl、DBI 和 DBD::Pg 在另一台机器上访问 Postgre 数据库吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24787302/