Instalasi PostgreSQL di CentOS 7
Instalasi PostgreSQL di CentOS 7
Berikut adalah cara install database PostgreSQL di Centos 7
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql15-server
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15
Masuk ke postgre
su -l postgres
psql
Buat user selevel root
CREATE USER root2 SUPERUSER PASSWORD 'disinipassnya';
atau
CREATE USER root2 SUPERUSER CREATEDB CREATEROLE PASSWORD 'disinipassnya';
atau
CREATE USER root2 SUPERUSER CREATEDB;
Enable Remote Login PostgreSQL
Edit file
nano /var/lib/pgsql/15/data/postgresql.conf
Uncomment baris berikut
listen_addresses = '*'
Edit file
nano /var/lib/pgsql/15/data/pg_hba.conf
Sesuaikan isi file
# IPv4 local connections:
host all all 0.0.0.0/0 md5
tip
METHOD can be "trust", "reject", "md5", "password", "scram-sha-256", "gss", "sspi", "ident", "peer", "pam", "ldap", "radius" or "cert". Note that "password" sends passwords in clear text; "md5" or "scram-sha-256" are preferred since they send encrypted passwords
Restart service
systemctl restart postgresql-15
Enable port PostgreSQL di firewall
firewall-cmd --add-port=5432/tcp --permanent
firewall-cmd --reload
Mengganti format password ke md5
Default nya adalah scram-sha-256
namun beberapa aplikasi db client tidak bisa connect, oleh karena itu mesti diubah ke format md5
nano /var/lib/pgsql/15/data/postgresql.conf
Sesuaikan baris berikut :
password_encryption = md5
Edit juga file pg_hba
nano /var/lib/pgsql/15/data/pg_hba.conf
Sesuaikan isi file seperti berikut :
host all all 0.0.0.0/0 md5
Edit password yang telah diberikan
ALTER ROLE root2 WITH PASSWORD 'disinipassbarunya';
Perintah PosgreSQL Tambahan
Perintah untuk lihat user dan role nya
\du
\du+
Perintah buat user yang lebih simple
Masuk dulu di psql
su -l postgres
psql
Buat user
createuser --interactive
Delete user
\du
DROP USER IF EXISTS user2;
DROP USER IF EXISTS user2, user3, user4;
Ganti password
ALTER ROLE postgres WITH PASSWORD 'root2'
Error Navicat saat login PostgreSQL
danger
authentication method 10 not supported
tip
solusinya adalah mengubah metode enkripsi dari scram-sha-256
ke md5
.
Sumber :
- https://www.postgresql.org/download/linux/redhat/
- Install dan PGadmin
- https://stackoverflow.com/questions/57975093/create-a-superuser-in-postgres
- https://phoenixnap.com/kb/delete-postgres-user
- https://phoenixnap.com/kb/postgres-create-user
- https://stackoverflow.com/a/64336274 (lengkap mengenai error authentication method 10 not supported)
- https://stackoverflow.com/questions/65967465/authentication-method-10-not-supported-postgressql
- https://stackoverflow.com/questions/67588076/why-do-i-get-error-type-10-authentication-not-supported-for-postgresql-13-even