PostgreSQL 12 설치 - 센터OS 7

3523 단어 데이터베이스
RPM Repositorie, 주소 다운로드https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm.CentOS에 업로드합니다.
mkdir postgresql
cd postgresql/

rpm -ivh pgdg-redhat-repo-latest.noarch.rpm

yum list | grep postgresql12
postgresql12.x86_64                         12.1-2PGDG.rhel7           pgdg12
postgresql12-contrib.x86_64                 12.1-2PGDG.rhel7           pgdg12
postgresql12-debuginfo.x86_64               12.1-1PGDG.rhel7           pgdg12
postgresql12-devel.x86_64                   12.1-2PGDG.rhel7           pgdg12
postgresql12-docs.x86_64                    12.1-2PGDG.rhel7           pgdg12
postgresql12-libs.x86_64                    12.1-2PGDG.rhel7           pgdg12
postgresql12-llvmjit.x86_64                 12.1-2PGDG.rhel7           pgdg12
postgresql12-odbc.x86_64                    12.00.0000-1PGDG.rhel7     pgdg12
postgresql12-plperl.x86_64                  12.1-2PGDG.rhel7           pgdg12
postgresql12-plpython.x86_64                12.1-2PGDG.rhel7           pgdg12
postgresql12-plpython3.x86_64               12.1-2PGDG.rhel7           pgdg12
postgresql12-pltcl.x86_64                   12.1-2PGDG.rhel7           pgdg12
postgresql12-server.x86_64                  12.1-2PGDG.rhel7           pgdg12
postgresql12-test.x86_64                    12.1-2PGDG.rhel7           pgdg12

PostgreSQL 12를 설치합니다.
yum install -y postgresql12.x86_64 postgresql12-contrib.x86_64 postgresql12-server.x86_64

데이터베이스를 초기화하다.
/usr/pgsql-12/bin/postgresql-12-setup initdb
Initializing database ... OK

데이터베이스를 시작합니다.
systemctl start postgresql-12

systemctl enable postgresql-12

postgreq 사용자의 비밀번호를 수정합니다.
passwd postgres
     postgres     。
     :
     :        
         :
passwd:               。


su - postgres
-bash-4.2$ psql
psql (12.1)
   "help"        .

postgres=# ALTER USER postgres with password '1111';
ALTER ROLE
postgres=# \q
-bash-4.2$ exit
  

데이터베이스 액세스 권한을 수정합니다.
vi /var/lib/pgsql/12/data/pg_hba.conf
......
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     all                                     peer
#host    replication     all             127.0.0.1/32            ident
#host    replication     all             ::1/128                 ident
host    all              all             0.0.0.0/0               md5

데이터베이스에 원격으로 접근할 수 있도록 합니다.
vi /var/lib/pgsql/12/data/postgresql.conf
# - Connection Settings -

listen_addresses = '*'                  # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
port = 5432                             # (change requires restart)

데이터베이스를 다시 시작합니다.
systemctl restart postgresql-12

좋은 웹페이지 즐겨찾기