Сброс пароля в PostgreSQL
Забыли пароль учетной записи postgres в PostgreSQL? Выполнить сброс не сложно. Для этого необходимо выполнить пару манипуляций.
1. Правим файл pg_hba.conf
Находим файл в папке Data директории установки PostgreSQL. В Windows путь выглядит примерно так c:\Program Files\PostgreSQL\9.2.4-1.1C\data\
В этом файле нужно найти такие строчки
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 md5
Меняем md5 на trust.
2. Удаляем файл pgpass.conf
В Windows этот файл находится в c:\Users\Administrator\AppData\Roaming\postgresql\
Здесь хранится старый пароль от PostgreSQL. Простое изменение хранимого здесь пароля мне не помогло. Поэтому я его просто удалил.
3. Меняем пароль в pgAdmin
Запускаем pgAdmin и нам предлагается ввести пароль. Если отметить галочку сохранить, то пароль будет сохранен в pgpass.conf и больше программой запрашиваться не будет.
Чтобы обеспечить безопасность использования паролей необходимо вернуть алгоритм шифрования md5. Для этого в файле pg_hba.conf параметр trust обратно меняем на md5.
Для подключения на локальном компьютере к PostgreSQL с помощью psql, pg_dump в локальных адресах IPv4 127.0.0.1/32 и IPv6 ::1/128 значение trust нужно оставить.
7 thoughts on “ Сброс пароля в PostgreSQL ”
Ты не сменил и не сбросил пароль. Ты отключил все механизмы защиты, поэтому он теперь пускает не с новым паролем, а вообще с ЛЮБЫМ. Строка trust как раз и отключает проверку пароля. А файл pgpass.conf нужен для того что бы утилитка pgAdmin могла туда сохранить пароль и не спрашивать его больше. Именно поэтому он храниться в твоем профиле, что бы никто другой не мог туда зяглянуть.
Пароль пользователя меняется командой ALTER USER user_name WITH PASSWORD ‘new_password’;
Удали статью, а то кучи начинающих «АДМИНОВ» понаоткрывают голую жопу по твоим советам.
- admin Автор записи 07.07.2019 в 16:05
Прежде чем писать такой комментарий
Строка trust как раз и отключает проверку пароля.
..внимательней читайте статью, там написано
параметр trust обратно меняем на md5
Про файл pgpass.conf тоже в статье сказано.
Так что с голой жопой останутся только такие же невнимательные как ты.
Глохни, петух. Как я смогу изменить пароль, если не могу на сервер зайти без пароля, придурок!
Тебе выше написали, что параметры доступа в pg_hba.conf изменены так, чтобы пустить потом тебя БЕЗ пароля с localhost. Да, когда меняете этот файл, перещапускать БД не забывайте.
Потом влетай в консоль psql -Upostgres -W -hlocalhost c пустым паролем, и меняй себе его наздоровье.
Затем возверни настройки обратно в md5 и перезапусти БД.
Виндовозники привыкли мышкой водить. Нет чтоб в терминале просто и со вкусом ALTER USER user_name WITH PASSWORD ‘new_password’;
На локальном компьютере это оказалось оптимальным решением. Конечно, в сочетании с обычной сменой пароля, когда смог попасть в админку. Если Вы и петух, то очень полезный для сообщества) Спасибо Вам!
Login Dialog¶

Use the fields in the Login dialog to authenticate your connection. There are two ways to authenticate your connection:
From pgAdmin version 4.21 onwards, support for LDAP authentication has been added. If LDAP authentication has been enabled for your pgAdmin application, you can use your LDAP credentials to log in to pgAdmin:
Provide the LDAP username in the Email Address/Username field.
Provide your LDAP password in the Password field.
Alternatively, you can use the following information to log in to pgAdmin:
Provide the email address associated with your account in the Email Address/Username field.
Provide your password in the Password field.
Click the Login button to securely log into pgAdmin.
Please note that if the pgAdmin server is restarted, then you will be logged out. You need to re-login to continue.
Recovering a Lost Password¶
If you cannot supply your password, click the Forgotten your password? button to launch a password recovery utility.
Provide the email address associated with your account in the Email Address field.
Click the Recover Password button to initiate recovery. An email, with directions on how to reset a password, will be sent to the address entered in the Email Address field.
If you have forgotten the email associated with your account, please contact your administrator.
Please note that your LDAP password cannot be recovered using this dialog. If you enter your LDAP username in the Email Address/Username field, and then enter your email to recover your password, an error message will be displayed asking you to contact the LDAP administrator to recover your LDAP password.
Avoiding a bruteforce attack¶
You have the possibility to lock an account by setting MAX_LOGIN_ATTEMPTS once it has reached the maximum number of login attempts. You can disable this feature by setting the value to zero.
Сброс пароля в PostgreSQL на Windows платформах
Забыли пароль учетной записи postgres в PostgreSQL? Выполнить сброс не сложно. Для этого необходимо выполнить пару манипуляций.
1. Правим файл pg_hba.conf
Находим файл в папке Data директории установки PostgreSQL. В Windows путь выглядит примерно так c:\Program Files\PostgreSQL\9.2.4-1.1C\data\
В этом файле нужно найти такие строчки
Меняем md5 на trust.
2. Удаляем файл pgpass.conf
В Windows этот файл находится в c:\Users\Administrator\AppData\Roaming\postgresql\
Здесь хранится старый пароль от PostgreSQL. Простое изменение хранимого здесь пароля мне не помогло. Поэтому я его просто удалил.
3. Меняем пароль в pgAdmin
Запускаем pgAdmin и нам предлагается ввести пароль. Если отметить галочку сохранить, то пароль будет сохранен в pgpass.conf и больше программой запрашиваться не будет.
Чтобы обеспечить безопасность использования паролей необходимо вернуть алгоритм шифрования md5. Для этого в файле pg_hba.conf параметр trust обратно меняем на md5.
Для подключения на локальном компьютере к PostgreSQL с помощью psql, pg_dump в локальных адресах IPv4 127.0.0.1/32 и IPv6 ::1/128 значение trust нужно оставить.
I forgot to configure login Email id and password while install pg admin 4. how i can change after installation
I am new to pgAdmin 4. I have forgot to setup of login Email id and password while install pgAdmin 4. How can I change after installation? Any one can help me?
![]()
5 Answers 5
As my friend @Almadani and @richyen post are completely right.
But If you are working on remote host databases its best to delete that folder.Such as it may on some instance[ssh]
After deletion of folder. you can simply create new credentials
You can also check it out from the blog. By the way the blog is from here.
I’m assuming that since you don’t remember your admin/password, you didn’t do much with pgAdmin yet. If that’s the case, you can move/remove the SQLite database out of the way and restart pgAdmin:
When you do this, you’ll be prompted for a password the next time you start up the app.
You can also dump the contents of the SQLite database before moving/removing: