postgresql 데이타베이스와 사용자 생성

postgresql 데이타베이스와 사용자 생성

포스트그레스 사용자와 데이타베이스 생성. Confluence 나 JIRA 설치용

Creating user

먼저 postgres 사용자로 전환

$ sudo -i -u postgres



  1. User 생성

    $ createuser jira --interactive Shall the new role be a superuser? (y/n) n Shall the new role be allowed to create databases? (y/n) y Shall the new role be allowed to create more new roles? (y/n) n $ createuser confluence --interactive $ createuser bamboo --interactive $ createuser bitbucket --interactive

    또는 psql 프롬프트에서도 가능

    # CREATE USER confluence WITH ENCRYPTED PASSWORD 'secret123';



Database 생성

  1. postgres 사용자로 전환

    $ sudo -i -u postgres



  2. DB 생성

    $ createdb jiradb -O jira --encoding='utf-8' --locale=en_US.utf8 --template=template0 $ createdb confluencedb -O confluence --encoding='utf-8' --locale=en_US.utf8 --template=template0 $ createdb bamboodb -O bamboo --encoding='utf-8' --locale=en_US.utf8 --template=template0 $ createdb bitbucketdb -O bitbucket --encoding='utf-8' --locale=en_US.utf8 --template=template0



또는 psql 프롬프트에서 입력 가능

$ sudo -i -u postgres psql



postgres=# CREATE DATABASE jiradb OWNER jira ENCODING 'utf-8'; postgres=# CREATE DATABASE confluencedb OWNER confluence ENCODING 'utf-8'; postgres=# CREATE DATABASE bamboodb OWNER bamboo ENCODING 'utf-8'; postgres=# CREATE DATABASE bitbucketdb OWNER bitbucket ENCODING 'utf-8';



Creating Role 생성

  1. psql 구동

    $ sudo -i -u postgres psql



  2. Role 생성

    postgres=# ALTER ROLE jira WITH PASSWORD 'password' ; postgres=# ALTER ROLE confluence WITH PASSWORD 'password' postgres=# ALTER ROLE bitbucket WITH PASSWORD 'password'; postgres=# ALTER ROLE bamboo WITH PASSWORD 'password';



연결 확인

옵션 대소문자 구분하니 주의



$ psql -U confluence -d confluencedb -W -h localhost
  • -U : username

  • -d : database name

  • -W : password 사용

  • -h: 연결할 호스트. 제외할 경우 "peer authentication failed" 에러 발생 가능

See Also

Ref