-
-
Save ismarsantos/28b62d8a9be1ce8d21f3bd436abd21bc to your computer and use it in GitHub Desktop.
sudo -u postgres psql -c 'SHOW config_file' | |
sudo nano /etc/postgresql/13/main/postgresql.conf | |
# uncomment line 59: | |
#------------------------------------------------------------------------------ | |
# CONNECTIONS AND AUTHENTICATION | |
#------------------------------------------------------------------------------ | |
# - Connection Settings - | |
listen_addresses = 'localhost' # what IP address(es) to listen on; | |
#------------------------------------------------------------------------------ | |
# Save file and restart | |
sudo service postgresql stop | |
sudo service postgresql start | |
# https://www.pgadmin.org/download/pgadmin-4-windows/ | |
# Download it here and install it. | |
# In the popup Create — Server window: | |
# General tab: I set Name to test | |
# Connection tab: I set Host name/address to 127.0.0.1 (Note: some post said you can set it as localhost, but it causes errors for me) | |
# port:5432 | |
# Leave maintenance database and Username as default postgres | |
# Password: whatever password you set up earlier for PostgreSQL in WSL 2, click Save password |
Perfect!
It is recommended to create a new superuser aside from
postgres
. The latter has a peer authentication type, which may cause an error when connecting by pgAdmin.To create a user, run the following in the terminal.
$ su - postgres $ createuser --interactive -P yourusername Enter password for new role: Enter it again: Shall the new role be a superuser? (y/n) yTest it by
$ psql -U yourusername -h 127.0.0.1 postgres
psql -U yourusername -h 127.0.0.1 postgres
This worked for me. thanks. One quick question. if i am able to do this then i guess i won't be needing pgAdmin?
It is recommended to create a new superuser aside from
postgres
. The latter has a peer authentication type, which may cause an error when connecting by pgAdmin.To create a user, run the following in the terminal.
$ su - postgres $ createuser --interactive -P yourusername Enter password for new role: Enter it again: Shall the new role be a superuser? (y/n) yTest it by
$ psql -U yourusername -h 127.0.0.1 postgres
worked for me, thx!
It is recommended to create a new superuser aside from
postgres
. The latter has a peer authentication type, which may cause an error when connecting by pgAdmin.To create a user, run the following in the terminal.
$ su - postgres $ createuser --interactive -P yourusername Enter password for new role: Enter it again: Shall the new role be a superuser? (y/n) yTest it by
$ psql -U yourusername -h 127.0.0.1 postgres
THANKS:))
This worked for me. Thank you.