카테고리 없음

postgres create user with md5 password: md5 해쉬로 postgres 유저 비밀번호 생성

seul chan 2020. 3. 19. 09:55
  • If make user named john with password abcedf, make md5 hash with password + username
$echo -n abcdefjohn | md5

4d9ceab746eb1791f153a8850f275954
  • Create user using md5 hash
  • Add md5 prefix to md5 hash
CREATE ROLE john LOGIN INHERIT ENCRYPTED PASSWORD 'md54d9ceab746eb1791f153a8850f275954';
  • Or alter user if already exists
ALTER ROLE john LOGIN INHERIT ENCRYPTED PASSWORD 'md54d9ceab746eb1791f153a8850f275954';

Then you can login with the password abcdef when login with john.

$ psql -U john
Password for user test:  # abcdef
psql
Type "help" for help.