当前位置: 首页 > Linux

在linux上安装PostgreSQL

时间:2023-04-06 02:27:13 Linux

,将最新的rpm包添加到系统库中。PostgreSQL将发布适用于所有Linux平台的rpm包,并且它的更新速度会比其他库快。地址:postresSQLlinuxrpm-Uvhhttps://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm列出可用的安装包yumlistpostgres*installPostgreSQLyuminstall-ypostgresql11-server.x86_64初始化数据库/usr/pgsql-11/bin/postgresql-11-setupinitdb只需要执行一次启动PostgreSQLsystemctlstartpostgresql-11设置自启动systemctlenablepostgresql-11查看运行状态systemctlstatuspostgresql-11在重置密码时启动chkconfigpostgresql-111)sudo-upostgrespsql2)ALTERUSERpostgresWITHPASSWORD'postgres';3)exit\qopenremoteaccessvi/var/lib/pgsql/11/data/postgresql.conf修改#listen_addresses='localhost'为listen_addresses='*',建议只监听内网IP。修改客户端认证配置文件pg_hba.confvi/var/lib/pgsql/11/data/pg_hba.conf,将IPv4区域下的127.0.0.1/32修改为0.0。0.0/0;修改ident为md5restartserviceservicepostgresql-11restartopenportfirewall-cmd--zone=public--add-port=5432/tcp--permanentreloadfirewallfirewall-cmd--reload