Skip to content

Instantly share code, notes, and snippets.

@Lazzlo2096
Created December 21, 2023 15:25
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/528743aacf7e020d903563936fe41e05 to your computer and use it in GitHub Desktop.
Save Lazzlo2096/528743aacf7e020d903563936fe41e05 to your computer and use it in GitHub Desktop.
# как зайти в БД postgres на wsl из pg_admin на windows хосте :
# 1. узнаём ip wsl:
$ ifconfig
inet 172.25.225.20
# или
PS> wsl hostname -I
172.25.225.20
## или
#$ ipconfig.exe # это не то
#IPv4-адрес. . . . . . . . . . . . : 172.25.224.1
## https://dba.stackexchange.com/questions/83984/connect-to-postgresql-server-fatal-no-pg-hba-conf-entry-for-host
# 2.1 добавляем эти строки:
$ sudo vim /etc/postgresql/14/main/postgresql.conf
```
listen_addresses = '*'
```
# 2.2 добавляем эти строки:
$ 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 перезапускаем постгрес:
```
service postgresql restart
```
# 3. теперь мы можем на windows-хосте коннектиться к postgres БД
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment