Skip to content

Instantly share code, notes, and snippets.

@Lazzlo2096
Last active December 21, 2023 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lazzlo2096/b20dba4baa354fff31e0134bf1b668d0 to your computer and use it in GitHub Desktop.
Save Lazzlo2096/b20dba4baa354fff31e0134bf1b668d0 to your computer and use it in GitHub Desktop.

Как найти файлы конфигурации:

Выберите один из методов

Вариант I. С помошью утилиты find:

sudo find / -type f -name "pg_hba.conf" -not -path "/mnt/*" 2>/dev/null # хуита, он просто пропускает?
sudo find /etc/ -type f -name "pg_hba.conf" 2>/dev/null

Вариант II. Или с помошью утилиты locate:

Источник: https://stackoverflow.com/questions/3602450/where-does-postgresql-store-configuration-conf-files

locate postgresql.conf

Вариант III. Или с помошью встроиных операций:

Источник: https://stackoverflow.com/questions/3602450/where-does-postgresql-store-configuration-conf-files

$ psql -U postgres      -c 'SHOW config_file'
$ sudo -u postgres psql -c 'SHOW config_file'

Как подключиться к базе данных PostgreSQL на WSL из pgAdmin на хосте Windows:

Шаг 1: Узнать IP WSL

$ ifconfig
172.25.225.20

Или

PS> wsl hostname -I
172.25.225.20

Примечание: не путать с ipconfig на windows.

Шаг 2: Настроить PostgreSQL в WSL

Источник: https://dba.stackexchange.com/questions/83984/connect-to-postgresql-server-fatal-no-pg-hba-conf-entry-for-host Как найти файлы конфигурации: см. файл ниже find configs.md.

2.1 Отредактировать файл postgresql.conf:

$ sudo vim /etc/postgresql/14/main/postgresql.conf

Добавить строку:

listen_addresses = '*'

2.2 Отредактировать файл pg_hba.conf:

$ sudo vim /etc/postgresql/14/main/pg_hba.conf

Добавить строку:

# TYPE DATABASE USER CIDR-ADDRESS  METHOD
host    all     all             172.25.225.20/0            scram-sha-256

2.3 Перезапустить PostgreSQL:

$ sudo service postgresql restart

Шаг 3: Подключение с хоста Windows

Теперь вы можете подключиться к базе данных PostgreSQL с вашего компьютера под управлением Windows.

$ psql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment