PostgreSQL15.2数据库安装

获取源代码

[root@master pg]# tar -zxvf postgresql-15.2.tar.gz

 

[root@master pg]#  cd postgresql-15.2/

 

·         编译,安装

[root@master postgresql-15.2]# ./configure

checking build system type... x86_64-pc-linux-gn

 

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 isn't looking in the proper directory.

Use --without-readline to disable readline support.

[root@master postgresql-15.2]# make

You need to run the 'configure' program first. See the file

'INSTALL' for installation instructions, or visit:

make: *** [all] Error 1

 

解决办法

[root@master postgresql-15.2]# rpm -qa | grep readline

readline-6.2-10.el7.x86_64

[root@master postgresql-15.2]# yum search readline

Loaded plugins: fastestmirror, langpacks

Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast

Determining fastest mirrors

 * base: mirrors.aliyun.com

 * extras: mirrors.bfsu.edu.cn

 * updates: mirrors.aliyun.com

=================================================================== N/S matched: readline ===================================================================

lua-readline.x86_64 : Lua interface to the readline and history libraries

perl-Term-ReadLine-Gnu.x86_64 : Perl extension for the GNU Readline/History Library

rakudo-Readline.x86_64 : Simple Perl 6 binding to GNU libreadline

readline-devel.i686 : Files needed to develop programs which use the readline library

readline-devel.x86_64 : Files needed to develop programs which use the readline library

readline-static.i686 : Static libraries for the readline library

readline-static.x86_64 : Static libraries for the readline library

tcl-tclreadline.x86_64 : GNU Readline extension for Tcl/Tk

tcl-tclreadline-devel.x86_64 : Development files for the tclreadline library

editline.x86_64 : A small compatible replacement for readline

linenoise.x86_64 : Minimal replacement for readline

perl-Term-UI.noarch : Term::ReadLine user interface made easy

readline.x86_64 : A library for editing typed command lines

readline.i686 : A library for editing typed command lines

rlwrap.x86_64 : Wrapper for GNU readline

 

  Name and summary matches only, use "search all" for everything.

[root@master postgresql-15.2]#  yum -y install -y readline-devel

 

 

configure: error: zlib library not found

If you have zlib already installed, see config.log for details on the

failure.  It is possible the compiler isn't looking in the proper directory.

Use --without-zlib to disable zlib support.

[root@master postgresql-15.2]# make

You need to run the 'configure' program first. See the file

'INSTALL' for installation instructions, or visit:

make: *** [all] Error 1

[root@master postgresql-15.2]# yum install zlib-devel

 

make

make[1]: Leaving directory `/data/pg/postgresql-15.2/config'

[root@master postgresql-15.2]# make all

创建用户

postgres 创建用户

 

[root@master postgresql-15.2]# useradd postgres

[root@master postgresql-15.2]# passwd postgres

Changing password for user postgres.

New password:

[root@master config]#

[root@master config]# chown -R postgres:postgres /data/

 

 

 

[root@master config]#

[root@master config]#

[root@master config]#

[root@master config]# su - postgres

Last login: Thu Mar 16 08:59:57 CST 2023 on pts/0

[postgres@master ~]$ mkdir -p /data/pgdata/

[postgres@master ~]$

初始化数据库

su - postgres

initdb -D /data/pgdata/

 

修改配置文件

 

cd /data/pgdata/

vi postgresql.conf

# 将该条配置反注释,将localhost 改成*

listen_addresses = '*'

修改访问控制文件

 

vi pg_hba.conf

# IPv4 local connections:

host    all             all             0.0.0.0/0            md5

启动数据库

[postgres@pgDatabase ~]$ pg_ctl -D /data/pgdata/ -l logfile start

server starting

进入数据库修改postgres 密码

 

psql

postgres=# ALTER USER postgres WITH PASSWORD 'postgres';

ALTER ROLE

这样就算全部完成了,远程也可以连接数据库了。


请使用浏览器的分享功能分享到微信等