Postgresql 포트번호 바꾸기
postgresql 서버를 실행되고 사용이 되는것을 확인하고 나서 port번호를 변경할 일이 생겼다.
포트변경 방법은 아주 쉽다.
1) postgres의 data 폴더로 이동한다.
$ cd /home/{USER_NAME}/postgres/data
2) postgresql.conf 파일의 값을 변경해야한다.
$ vi postgresql.conf
3) 아래로 내리면 #port=5432 이라고 되어있을 것이다.
해당 부분은 port : 내가 원하는 번호로 변경한다.
#port = 5432 >>> port = 내가 원하는 번호
4) 서버를 재시작한다.
$ /home/{USER_NAME}/postgres/bin/pg_ctl -D /home/{USER_NAME}/postgres/data restart
5) 서버를 재시작해도 에러가 발생할것이다.
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed:
그런 파일이나 디렉터리가 없습니다 no such file or directory
6) 이후로는 조금 번거롭지만 로그인시 아래 명령어를 시행해준다.
$ /home/{USER_NAME}/postgres/bin/psql -U user_name postgres -p 1000
쉽게 말하면 변경된 포트의 번호를 써줘야한다.
7) 서버는 꼭 재시작을 해야한다.
$ /home/{USER_NAME}/postgres/bin/pg_ctl -D /home/{USER_NAME}/postgres/data restart
끝.
728x90
반응형