安装postgreSQL出现configure:error:readline library not found解决方法及pg安装全过程

本文详细记录了解决 PostgreSQL 安装过程中遇到的 readline 库未找到错误的过程。通过检查系统环境、确认 readline 包已安装、使用 yum 搜索相关依赖包并安装 readline-devel,最终成功解决了配置失败的问题。文章还提供了从配置失败到成功安装 PostgreSQL 的完整步骤,包括初始化数据库、启动服务器、创建和连接数据库等操作。
 
在安装postgreSQL的过程中遇到一个问题,在执行 configure
过程中报以下错误,configure: error: readline library not found ,可是我在系统中安装
readline 包了,

1 环境信息

2 根据提示,测试了下 configre命令,果然报这个错
[root@HK81-107 postgresql-9.0.0]# ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking if gcc supports -Wdeclaration-after-statement... yes
checking if gcc supports -Wendif-labels... yes
checking if gcc supports -fno-strict-aliasing... yes
checking if gcc supports -fwrapv... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking allow thread-safe client libraries... yes
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with Kerberos 5 support... no
checking whether to build with PAM support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for tar... /bin/tar
checking whether ln -s works... yes
checking for gawk... gawk
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for bison... no
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from CVS nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from CVS nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /usr/bin/perl
configure: using perl 5.8.8
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing fdatasync... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for -lreadline... no
checking for -ledit... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isnt looking in the proper directory.
Use --without-readline to disable readline support.

     根据提示,应该是没有安装 readline包。

3 检查系统是否安装 readline 包
[root@HK81-107 postgresql-9.0.0]# rpm -qa | grep readline
readline-5.1-3.el5

   说明系统已经安装了 readline包。

4 通过 yum 搜索相关的 readline 包
[root@HK81-107 postgresql-9.0.0]# yum search readline
lftp.i386 : A sophisticated file transfer program
lftp.i386 : A sophisticated file transfer program
php-readline.i386 : Standard PHP module provides readline library support
lftp.i386 : A sophisticated file transfer program
readline.i386 : A library for editing typed command lines.
compat-readline43.i386 : The readline 4.3 library for compatibility with older software.
readline-devel.i386 : Files needed to develop programs which use the readline library.
readline.i386 : A library for editing typed command lines.

 根据提示,有一个包引起了注意 "readline-devel", 猜想可能与这个包有关。
 
5 安装 readline-devel 包
[root@HK81-107 postgresql-9.0.0]# yum -y install -y readline-devel
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package readline-devel.i386 0:5.1-3.el5 set to be updated
--> Processing Dependency: libtermcap-devel for package: readline-devel
--> Running transaction check
---> Package libtermcap-devel.i386 0:2.0.8-46.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 readline-devel          i386       5.1-3.el5        base              146 k
Installing for dependencies:
 libtermcap-devel        i386       2.0.8-46.1       base               56 k

Transaction Summary
=============================================================================
Install      2 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        

Total download size: 201 k
Downloading Packages:
(1/2): libtermcap-devel-2 100% |=========================|  56 kB    00:00    
(2/2): readline-devel-5.1 100% |=========================| 146 kB    00:00    
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: libtermcap-devel             ######################### [1/2]
  Installing: readline-devel               ######################### [2/2]

Installed: readline-devel.i386 0:5.1-3.el5
Dependency Installed: libtermcap-devel.i386 0:2.0.8-46.1
Complete!

6 再次执行 configure 成功。

7 还有一种解决方法:在configure 加上参数 --without-readline ,不过这样就不可以在命令行里面输入了,所以不建议这样。。。

8 configure 成功之后接着就是make了

9 make之后就是make install之后安装成功的话就会出现如下图所示的界面

 

图片

 10.修改postgreSQL安装目录的权限,默认的安装目录在/usr/local/pgSQL下

修改权限命令为chmod -R 777 /usr/local/pgSQL

运行之后pgSQL目录下面的所有文件都会有XWR(X:可执行,W:可写,R:可读)权限。命令中的-R参数说明是递归的把文件夹pgSQL目录及其目录下的所有文件都修改为相应的权限,777就是代表加上对本用户,本用户组的其他用户和不是这个组的用户增加XWR权限。

 

11.

到此,PostgreSQL的安装完成了,接下来可以试着用用这个开源数据库啦…

1):首先是初始化数据库。进入刚刚安装PG的文件夹/home/pg/postgr(这是我安装pg的目录,默认的安装目录是在/usr/local/pgSQL下),输入./bin/initdb –D ../data. 这里的命令格式还需要查明白,特别是-D等参数的意义。这样会在postgr下面产生一个data文件夹。

2):启动数据库服务器。./bin/postmaster –D ./data&. 其中&的意义需要弄明白,差这一个符号就会导致一定的问题,貌似启动数据库服务器还可以使用另外的命令:/bin/postgres -D ./data 或者是 ./bin/pg_ctl -D ./data -l logfile start。这些命令的区别可以自己查查手册或者咨询一下助教。

 

图片

 

3):在另外一个命令行下面,创建一个本地数据库。./bin/createdb testdb,其中testdb是数据库名。在data目录下会产生一个文件夹

 

图片

 

4):链接数据库服务器。./bin/psql testdb. 此时,输入help可以获得帮助。见下图

 

图片

 

 

5):访问数据库。这里就是输入sql命令了,以后调试的入口就是这里吧。结束后按\q退出。

 

6):最后是关闭数据库服务器。./bin/pg_ctl stop –D ./data.

12.That's all!

 

<think> 我们已知用户在配置PostgreSQL 14.14时遇到错误:configure: error: library 'xml2' (version >= 2.6.23) is required for XML support 根据引用[1]和引用[2]提供的信息,我们需要安装满足版本要求的libxml2库(即xml2库)以及可能的开发包。 解决方案步骤: 1. 确认系统是否已安装libxml2库,并检查版本是否满足要求(>=2.6.23)。 可以使用命令:`xml2-config --version` 或 `pkg-config libxml-2.0 --modversion` 2. 如果未安装或版本过低,则需要安装或升级libxml2库。 3. 根据不同的操作系统,安装方法有所不同: - 对于基于Debian的系统(如Ubuntu): ```bash sudo apt-get update sudo apt-get install libxml2-dev ``` - 对于基于RPM的系统(如CentOS、RHEL): ```bash sudo yum install libxml2-devel # 或者使用dnf(较新版本): sudo dnf install libxml2-devel ``` 4. 如果系统自带的软件源中的libxml2版本过低,可能需要从源代码编译安装。但通常软件源中的版本足够新。 5. 安装完成后,再次运行PostgreSQLconfigure脚本,应该可以解决该问题。 6. 如果问题仍然存在,可能需要确保开发包安装正确,并且路径被正确识别。可以设置环境变量`PG_CONFIG`指向正确的配置路径(但通常不需要)。 7. 引用[2]中提到,在安装psycopg2时遇到类似问题,需要安装postgresql-devel包。但是这里我们遇到的是libxml2的问题,所以重点应放在libxml2上。不过,安装PostgreSQL的开发包(如postgresql-devel或postgresql-server-dev)也可能有助于解决依赖问题。 8. 另外,根据引用[2],有时还需要安装其他依赖包,例如libicu-devel。所以,如果安装libxml2-devel后仍有其他错误,可能需要安装其他开发包。 9. 最后,重新运行configure、make、make install步骤。 注意:用户是在配置(configure)阶段报错,所以确保在运行configure之前安装好所需的开发包。 总结:安装libxml2的开发包(通常名为libxml2-dev或libxml2-devel)是解决此问题的关键。 相关问题: 1. 如何检查系统中已安装的libxml2版本? 2. 如果软件源中没有足够新的libxml2,如何从源码安装? 3. 在编译安装PostgreSQL时,如何指定libxml2的路径? </think> ### PostgreSQL 14.14配置错误解决方案 针对您遇到的`configure: error: library 'xml2' (version >= 2.6.23) is required for XML support`错误,以下是完整的解决方案步骤: #### 1. **安装libxml2开发包** - **Ubuntu/Debian系统**: ```bash sudo apt update && sudo apt install libxml2-dev ``` 验证安装:`xml2-config --version`(需显示≥2.6.23) - **CentOS/RHEL系统**: ```bash sudo yum install libxml2-devel # 或较新系统 sudo dnf install libxml2-devel ``` 验证安装:`rpm -q libxml2-devel --info | grep Version` #### 2. **解决依赖问题** 若仍报错,可能需补充安装相关依赖: ```bash # Ubuntu/Debian sudo apt install build-essential zlib1g-dev # CentOS/RHEL sudo yum groupinstall "Development Tools" sudo yum install zlib-devel ``` #### 3. **配置环境变量** 指定库路径(适用于自定义安装路径): ```bash export XML2_CONFIG=/usr/bin/xml2-config # 使用which xml2-config确认路径 ./configure --with-libxml ``` #### 4. **重新编译PostgreSQL** ```bash make clean ./configure make sudo make install ``` #### 5. **验证解决** 检查配置日志: ```bash grep "XML support" config.log # 应显示"checking for libxml... yes" ``` > **关键说明**: > - 开发包名差异:`libxml2-dev` (Debian) / `libxml2-devel` (RHEL)[^1] > - 必须同时安装运行时库和开发头文件 > - Docker环境中需在构建镜像阶段安装开发包[^2] ### 相关问题 1. PostgreSQL编译安装时如何解决其他常见依赖错误(如readline、zlib)? 2. 在Docker容器中编译PostgreSQL如何永久解决依赖问题? 3. 如何验证PostgreSQL的XML扩展功能是否成功启用? [^1]: 不同Linux发行版的开发包命名规范差异 [^2]: 容器环境下需在Dockerfile中固化依赖安装步骤
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值