вторник, 18 октября 2016 г.

Сброс пароля пользователя postgres в PostgreSQL


  1. find the file pg_hba.conf - it may be located, for example in /etc/postgresql-9.1/pg_hba.conf.
    cd /etc/postgresql-9.1/
  2. Back it up
    cp pg_hba.conf pg_hba.conf-backup
  3. place the following line (as either the first uncommented line, or as the only one):
    local all all trust
  4. restart your PostgreSQL server (e.g., on Linux:)
    sudo /etc/init.d/postgresql restart
  5. you can now connect as any user. Connect as the superuser postgres (note, the superuser name may be different in your installation. In some systems it is called pgsql, for example.)
    psql -U postgres
  6. Reset password
    ALTER USER my_user_name with password 'my_secure_password';
  7. Restore the old pg_hba.conf as it is very dangerous to keep around
    cp pg_hba.conf-backup pg_hba.conf
  8. restart the server, in order to run with the safe pg_hba.conf
    sudo /etc/init.d/postgresql restart

Комментариев нет:

Отправить комментарий