Rangkuman Install Database PostgreSQL di Centos7
Configure Yum Repository
#rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
Repository info: https://yum.postgresql.org/repopackages.php#pg11
Install PostgreSQL11
#yum install postgresql11-server
Initialize PGDATA
#/usr/pgsql-11/bin/postgresql-11-setup initdb
Start PostgreSQL
#systemctl enable postgresql-11.service
#systemctl start postgresql-11.service
Verify
su - postgres -c "psql"
psql (11.0)
Type "help" for help.
postgres=#
Create a password for user postgres for security purpose.
\password postgres
Enable remote Acess to PostgreSQL
Edit the file /var/lib/pgsql/11/data/postgresql.conf and set Listen address to your server IP address or “*” for all interfaces.
listen_addresses = '192.168.18.9'
Also set PostgreSQL to accept remote connections
#vim /var/lib/pgsql/11/data/pg_hba.conf
# Accept from anywhere
host all all 0.0.0.0/0 md5
# Accept from trusted subnet
host all all 192.168.18.0/24 md5
Restart service
#systemctl restart postgresql-11
Set PostgreSQL admin user’s password
#su - postgres
bash-4.2$ psql -c "alter user postgres with password 'skill39'"
ALTER ROLE
-bash-4.2$
Create a test user and database
-bash-4.2$ createuser test_user
-bash-4.2$ createdb test_db -O test_user
-bash-4.2$ grant all privileges on database test_db to test_user;
Login as a test_user user try to create a table on the Database.
#psql -U test_user -h localhost -d test_db
#rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
Repository info: https://yum.postgresql.org/repopackages.php#pg11
Install PostgreSQL11
#yum install postgresql11-server
Initialize PGDATA
#/usr/pgsql-11/bin/postgresql-11-setup initdb
Start PostgreSQL
#systemctl enable postgresql-11.service
#systemctl start postgresql-11.service
Verify
su - postgres -c "psql"
psql (11.0)
Type "help" for help.
postgres=#
Create a password for user postgres for security purpose.
\password postgres
Enable remote Acess to PostgreSQL
Edit the file /var/lib/pgsql/11/data/postgresql.conf and set Listen address to your server IP address or “*” for all interfaces.
listen_addresses = '192.168.18.9'
Also set PostgreSQL to accept remote connections
#vim /var/lib/pgsql/11/data/pg_hba.conf
# Accept from anywhere
host all all 0.0.0.0/0 md5
# Accept from trusted subnet
host all all 192.168.18.0/24 md5
Restart service
#systemctl restart postgresql-11
Set PostgreSQL admin user’s password
#su - postgres
bash-4.2$ psql -c "alter user postgres with password 'skill39'"
ALTER ROLE
-bash-4.2$
Create a test user and database
-bash-4.2$ createuser test_user
-bash-4.2$ createdb test_db -O test_user
-bash-4.2$ grant all privileges on database test_db to test_user;
Login as a test_user user try to create a table on the Database.
#psql -U test_user -h localhost -d test_db
Komentar