[DB] POSTGRESQL

[PostgreSQL] postgresql job for postgresql-11.service failed because the control process exited with error code

mewoni 2020. 6. 26. 12:40
반응형

postgresql service를 start, restart 할 때 종종 발생하는 오류.

[root@localhost ~ ]$ systemctl start postgresql-11.service
[root@localhost ~ ]$ systemctl restart postgresql-11.service

job for postgresql-11.service failed because the control process exited with error code. ~~~ 

 

저 오류는 보통 pg_hba.conf 파일의 접속 변수 또는 method에 오류가 있어 서비스 시작을 위한 파일 경로를 찾지 못할 때 나타납니다. 

 

[root@localhost ~ ]$ systemctl enable postgresql-11.service
[root@localhost ~ ]$ systemctl status postgresql-11.service

status 로 서비스 상태 확인

 

vi /var/lib/pgsql/11/data/pg_hba.conf

postgresql의 외부접속 및 환경변수 설정 파일에 들어갑니다. (10이후 버전의 default 경로는 위와 같습니다.)

 

host    all   all    127.0.0.1/32    trust
host    all   all    0.0.0.0/0    trust

 method 부분을 trust로 바꾼 후 저장하고 나옵니다.

 

[postgres@localhost ~]$ su -
//비밀번호 입력

[root@localhost ~]$ systemctl restart postgresql-11.service

postgresql의 환경설정이 변경되었으므로 재시작 명령어를 통해 재부팅해줍니다.

 

[root@localhost ~ ]$ su - postgres
[postgres@localhost ~ ]$ psql

postgres=# alter user postgres with password '[password]';
ALTER USER

postgres 계정으로 psql 접속해서 postgres의 비밀번호 초기화합니다.

 

postgres=# \c [user_name]

그 후 원하는 database 계정으로 접속합니다. 

 

 

반응형