Postgresql-12.5 安装及配置 -银河麒麟V10服务器版本
创始人
2025-01-19 16:33:12
0次

Postgresql-12.5 安装及配置

环境基于银河麒麟V10 服务器版本操作
此安装步骤Linux操作系统几乎通用

下载数据库安装包

链接:https://pan.baidu.com/s/1wt4Yjwv79W-fCd4tlMC4-w
提取码:0117

1.下载依赖

可以用系统自带的依赖库下载

yum install -y openssl openssl-devel pam pam-devel libxml2 libxml2-devel libxslt libxslt-devel perl perl-devel install perl-ExtUtils-Embed readline readline-devel zlib zlib-devel gettext gettext-devel bison flex gcc gcc-c++ readline-devel 

我自己下载的有离线安装包
链接:https://pan.baidu.com/s/1krNqdXfK4qMbEQweXH2gMA
提取码:0117

2.读入数据

上传postgresql-12.5.tar.gz安装包,我的放在了/root/postgresql-12.5文件夹下解压

tar -zvxf postgresql-12.5.tar.gz 

3.创建文件路径,并将解压后的文件复制到该路径下

上传postgresql-12.5.tar.gz安装包,我的放在了/root/postgresql-12.5文件夹下解压

[root@localhost ~]# mkdir -p /export/servers/app/postgresql-12.5  

创建文件路径,并将解压后postgresql-12.5的文件复制到export/servers/app/postgresql-12.5 路径下

4.配置安装

上传postgresql-12.5.tar.gz安装包,我的放在了/root/postgresql-12.5文件夹下解压

 [root@localhost postgresql-12.5]# ./configure --prefix=/export/servers/app/postgresql-12.5 &&make &&make install   

报错的话按照报错去下载依赖文件,安装完成之后再次安装
提示:PostgreSQL installation complete.
表示安装完成

5.添加环境变量

 [root@localhost postgresql-12.5]# vim /etc/profile 

把光标拉至最下面然后按键 i 后将下面的复制到里面

export PGHOME=/export/servers/app/postgresql-12.5 export PGDATA=/export/servers/data/pgsql/ export PATH=$PGHOME/bin:$PATH export LANG=en_US.utf8 export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH 

操作完之后按EXC 输入:wq 保存并退出

#刷新并使文件生效

 [root@localhost postgresql-12.5]#  source /etc/profile 

6.创建数据目录

 [root@localhost postgresql-12.5]#  useradd postgres  [root@localhost postgresql-12.5]#  mkdir -p /export/servers/data/pgsql/  [root@localhost postgresql-12.5]#  chown postgres:postgres /export/servers/data/pgsql/  [root@localhost postgresql-12.5]#  ll 

在这里插入图片描述

7.初始化数据库

切换用户

[root@localhost postgresql-12.5]# su - postgres 

进入相对路劲

[postgres@localhost postgresql-12.5]$ cd /export/servers/app/postgresql-12.5/bin 

使用initdb启动

[postgres@localhost bin]$  /export/servers/app/postgresql-12.5/bin/initdb -D /export/servers/data/pgsql/ 

8.修改监听端口

[postgres@localhost bin]$ vim /export/servers/data/pgsql/postgresql.conf 

找到对应的地方添加一条

# - Connection Settings-      listen_addresses = '*' 

9.启动pg_ctl

[postgres@localhost bin]$ /export/servers/app/postgresql-12.5/bin/pg_ctl -D /export/servers/data/pgsql/ -l logfile start 
waiting for server to start..../bin/sh: logfile: Permission denied stopped waiting pg_ctl: could not start server Examine the log output.

启动服务

[postgres@localhost bin]$ pg_ctl start 
waiting for server to start....2023-03-03 11:27:58.887 CST [41939] LOG: starting  PostgreSQL 12.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.0, 64-bit 2023-03-03 11:27:58.888 CST [41939] LOG: listening on IPv4 address "0.0.0.0", port 5432 2023-03-03 11:27:58.888 CST [41939] LOG: listening on IPv6 address "::", port 5432 2023-03-03 11:27:58.890 CST [41939] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2023-03-03 11:27:58.908 CST [41940] LOG: database system was shut down at 2023-03-03 11:12:37 CST 2023-03-03 11:27:58.911 CST [41939] LOG: database system is ready to accept connections done server started 

10.验证5432端口

[postgres@localhost bin]$ netstat -anp | grep 5432 

在这里插入图片描述

11.登录并修改postgres密码

切换用户

[root@localhost pgsql]# su - postgres 

登录数据库

[postgres@localhost pgsql]# psql 

修改用户密码

postgres=# alter user postgres with password '输入修改的密码'; 

12.修改是否需要密码登录数据库

修改为md5表示用密码登录,如果为trust表示不需要密码

[postgres@localhost bin]$ cd /export/servers/data/pgsql/ [postgres@localhost bin]$ vim pg_hba.conf 

在这里插入图片描述
修改配置文件后需要重启

[postgres@localhost pgsql]$ /export/servers/app/postgresql-12.5/bin/pg_ctl -D /export/servers/data/pgsql/ -l logfile restart 

总结

以上就是postgresql的安装配置内容,我通过别的博主的帖子学习写的仅供学习,如有侵权请联系我删除
QQ:3356650288

主要内容来源:https://www.cnblogs.com/liunaixu/p/17175202.html

相关内容

热门资讯

最新开挂!微信微乐小程序游戏辅... 最新开挂!微信微乐小程序游戏辅助脚本,微信小程序辅助器免费版在进入微信微乐小程序游戏辅助脚本软件靠谱...
最新透视挂!微乐小程序免费黑科... 最新透视挂!微乐小程序免费黑科技,微信小程序微乐房间有技巧吗1、微乐小程序免费黑科技透视辅助软件激活...
最新辅助!微信微乐小程序修改器... 最新辅助!微信微乐小程序修改器,微乐陕西小程序破解器下载1、微信微乐小程序修改器脚本辅助下载、微信微...
最新透视挂!微信微乐小程序有挂... 最新透视挂!微信微乐小程序有挂黑科技,微乐家乡麻将辅助1、下载好微信微乐小程序有挂黑科技脚本下载之后...
最新开挂!微乐家乡麻将自建房辅... 最新开挂!微乐家乡麻将自建房辅助app,微乐小程序自建房辅助下载1、打开软件启动之后找到中间准星的标...
最新透视挂!微乐小程序辅助工具... 最新透视挂!微乐小程序辅助工具,如何下载微乐自建房黑科技入口1、首先打开微乐小程序辅助工具辅助器下载...
最新开挂!微乐家乡麻将自建房开... 最新开挂!微乐家乡麻将自建房开挂,微信小程序微乐房间的挂多少钱一、微乐家乡麻将自建房开挂可以开透视的...
最新辅助!微信微乐辅助免费,微... 最新辅助!微信微乐辅助免费,微乐小程序自建房透视免费1、游戏颠覆性的策略玩法,独创攻略技巧玩法,可透...
最新透视挂!小程序微乐游戏辅助... 最新透视挂!小程序微乐游戏辅助器,微乐自建房脚本入口1、下载好小程序微乐游戏辅助器透视辅助下载之后点...
最新辅助!微信微乐小程序辅助器... 最新辅助!微信微乐小程序辅助器免费安装,微乐小程序免费黑科技在线下载1、金币登录送、破产送、升级送、...