예전 centos 할 때 랑은 또 경로가 달라져서 헷갈리네

 

설정 변경

# cat /etc/postgresql/15/main/pg_hba.conf 
local   all             postgres                                peer

# 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            scram-sha-256
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256

 

서비스 재기동

$ sudo systemctl restart postgresql

 

postgres 계정으로 로그인 후 계정 및 database 생성

pi@raspberrypi:~ $ sudo su - postgres
postgres@raspberrypi:~$ psql
psql (15.7 ( 15.7-0+deb12u1))
Type "help" for help.

postgres=# create user username with password 'userpassword';
CREATE ROLE
postgres=# create database userdb;
CREATE DATABASE
materials=> \q
postgres@raspberrypi:~$

 

일반 계정에서 특정 사용자로 로그인

pi@raspberrypi:~ $ psql -U username userdb
Password for user username: 
psql (15.7 ( 15.7-0+deb12u1))
Type "help" for help.

userdb=> \q

 

[링크 : https://zipeya.tistory.com/entry/postgresql-DB생성-및-접속-시-Peer-authentication에러-발생-시-해야할-것]

'프로그램 사용 > postgreSQL' 카테고리의 다른 글

라즈베리에 phppgadmin. 안되잖아?  (0) 2024.07.24
phppgadmin  (0) 2024.07.23
postgresql cli  (0) 2024.07.21
psql copy to  (0) 2020.02.10
postgresql 제약조건 관련  (0) 2020.02.07
Posted by 구차니