Spent a few hours trying to configure PotgreSQL and DBeaver on wsl. Hope this helps.
Installing postgresql on wsl terminal
$ sudo apt update
$ sudo apt install postgresql postgresql-contrib
$ psql --version
- Give it a password that we will use in Dbeaver when testing connection.
$ sudo passwd postgres
Restart Terminal.
Check status and start PostgreSQL service.
$ sudo service postgresql status
$ sudo service postgresql start
- You should get a prompt asking for your password.
If you didn't, then type :
$ su - postgres
$ psql
- After entering your password you should see this
postgres=#
- Keep terminal open
DBeaver Setup
Open DBeaver after installing from here
Ctrl - Shift - N to make a new connection and select PostgreSQL.
Fill your password you entered earlier and click test connection.
- It should ask you to download some drivers. After downloading it should be working.
If you get an error, lets try reseting password and creating dummydb.
- go back to your terminal \q out and
$ sudo -u postgres createuser <username>
$ sudo -u postgres createdb <dummydbname>
$ sudo -u postgres psql
psql=# alter user postgres with encrypted password '<password>'
psql=# grant all privileges on database <dbname> to postgres
Close DBeaver and retry testing your connection.
If you get an connection error
sudo ufw allow 5432/tcp
# You should see "Rules updated" and/or "Rules updated (v6)"
sudo service postgresql restart
- Open powershell as admin
wsl --shutdown
Start postgresql service and Retry connection.
Top comments (0)