Каково имя пользователя/пароль суперпользователя по умолчанию для пост-ГРЭС после новой установки?

Как насчет инструкций по содержанию? Хранение разумной электронной почты поможет помешать Вам то, чтобы быть отмеченным как производитель спама в различных системах. Обучите свои клиенты стараться не передавать "забавный материал" всем в их списке контактов, не регистрации для почтовых обзоров или новостных рассылок, и использовать разумные вредоносные механизмы защиты для удержаний от становления частью ботнета спама...

385
задан 21 September 2017 в 17:21
5 ответов

CAUTION The answer about changing the UNIX password for "postgres" through "$ sudo passwd postgres" is not preferred, and can even be DANGEROUS!

This is why: By default, the UNIX account "postgres" is locked, which means it cannot be logged in using a password. If you use "sudo passwd postgres", the account is immediately unlocked. Worse, if you set the password to something weak, like "postgres", then you are exposed to a great security danger. For example, there are a number of bots out there trying the username/password combo "postgres/postgres" to log into your UNIX system.

What you should do is follow Chris James's answer:

sudo -u postgres psql postgres

# \password postgres

Enter new password: 

To explain it a little bit. There are usually two default ways to login to PostgreSQL server:

  1. By running the "psql" command as a UNIX user (so-called IDENT/PEER authentication), e.g.: sudo -u postgres psql. Note that sudo -u does NOT unlock the UNIX user.

  2. by TCP/IP connection using PostgreSQL's own managed username/password (so-called TCP authentication) (i.e., NOT the UNIX password).

So you never want to set the password for UNIX account "postgres". Leave it locked as it is by default.

Of course things can change if you configure it differently from the default setting. For example, one could sync the PostgreSQL password with UNIX password and only allow local logins. That would be beyond the scope of this question.

538
ответ дан 28 November 2019 в 19:13

Вы управляете пост-ГРЭС через пользователя postgres, как так:

# su - postgres
$ createdb mydb
$ psql -s mydb
# create user someuser password 'somepassword';
# GRANT ALL PRIVILEGES ON DATABASE mydb TO someuser;
64
ответ дан 28 November 2019 в 19:13

Введите в командную строку:

$ sudo -u postgres psql postgres
postgres=# \password postgres

Вот увидишь:

Enter new password: 
Enter it again:
168
ответ дан 28 November 2019 в 19:13

Если вы пытаетесь получить доступ к оболочке PostgreSQL, вы можете ввести:

psql -U postgres my_database

Где my_database - имя вашей базы данных.

]
5
ответ дан 28 November 2019 в 19:13

В Windows выполните следующие действия (ВАЖНО: используйте учетную запись администратора Windows ):

  1. После установки откройте \ data \ pg_hba .conf .

  2. Измените эти две строки и замените «md5» на «trust»:

    host all all 127.0.0.1/32 md5

    host all all :: 1/128 md5

  3. Перезапустите службу PostgreSQL (может быть необязательно).

  4. (Необязательно) Откройте командную строку и измените кодовую страницу на 1252:

    cmd.exe / c chcp 1252

  5. Войдите в PostgreSQL. Не потребуется пароль (обратите внимание на параметр -U в верхнем регистре):

    psql -U postgres

  6. (Необязательно, рекомендуется из соображений безопасности). Измените пароль пользователя postgres :

    \ password postgres

    и измените «trust» обратно на «md5» в pg_hba.conf .

21
ответ дан 28 November 2019 в 19:13

Теги

Похожие вопросы