摘要:
1、下载
https://www.postgresql.org/
上传安装包到服务器(rz工具)
[root@centos7-6 ~]# mkdir /pg-rpm[root@centos7-6 ~]# rzrz waiting to receive.Starting zmodem transfer. Press Ctrl+C to cancel.Transferring postgresql12-12.2-1PGDG.rhel7.x86_64.rpm... 100% 2773 KB 2773 KB/sec 00:00:01 0 Errors Transferring postgresql12-libs-12.2-1PGDG.rhel7.x86_64.rpm... 100% 758 KB 758 KB/sec 00:00:01 0 Errors Transferring postgresql12-server-12.2-1PGDG.rhel7.x86_64.rpm... 100% 13275 KB 13275 KB/sec 00:00:01 0 Errors
[root@centos7-6 ~]# cd /pg-rpm/[root@centos7-6 pg-rpm]# ll -htotal 17M-rw-r--r--. 1 root root 2.8M Apr 5 00:33 postgresql12-12.2-1PGDG.rhel7.x86_64.rpm-rw-r--r--. 1 root root 759K Apr 5 00:36 postgresql12-libs-12.2-1PGDG.rhel7.x86_64.rpm-rw-r--r--. 1 root root 13M Apr 5 00:41 postgresql12-server-12.2-1PGDG.rhel7.x86_64.rpm[root@centos7-6 pg-rpm]#
安装
[root@centos7-6 pg-rpm]# rpm -ivh postgresql12-libs-12.2-1PGDG.rhel7.x86_64.rpm[root@centos7-6 pg-rpm]# rpm -ivh postgresql12-12.2-1PGDG.rhel7.x86_64.rpm [root@centos7-6 pg-rpm]# rpm -ivh postgresql12-server-12.2-1PGDG.rhel7.x86_64.rpm
初始化数据库并设置自启动
/usr/pgsql-12/bin/postgresql-12-setup initdb systemctl enable postgresql-12systemctl start postgresql-12
systemctl status postgresql-12
也可以使用PG自带的工具pg_ctl
配置环境变量
-bash-4.2$ pwd/var/lib/pgsql-bash-4.2$ -bash-4.2$ vi .bash_profile
#追加内容export PATH=$PATH:/usr/pgsql-12/bin
-bash-4.2$ source .bash_profile
[root@centos7-6 ~]# su - postgres-bash-4.2$ pg_ctl stop-bash-4.2$ pg_ctl start-bash-4.2$ pg_ctl status