I'm new to SQL and am trying to configure and Ubuntu Server 14.04 VM to connect to SQL Workbench x64 on the localhost. Below are my settings for the Virtual machine's port forwarding and the error I receive when When trying to connect.
Oracle Virtual box Port forwarding Settings:
FTP = 127.0.0.1:2020 -> 10.0.2.15:20
HTTP = 127.0.0.1:8080 -> 10.0.2.15:80
SQL (Not Sure) = 127.0.0.1:5432 -> 10.0.2.15:5432
SQL (Service) = 127.0.0.1:1156 -> 15.0.2.15:1156
SSH (Data Transfer) = 127.0.0.1:2222 -> 10.0.2.15:22
Error When Connecting to postgres from MySQL workbench:
Failed to Connect to MySQL at 127.0.0.1:1156 with user dj
Lost connection to MySQL server at 'reading initial communication packet', system error: 0
If I understand what I've done, I've forwarded the port that postgres runs on inside the virtual machine to the same port on the local host. Also, i've used ufw to allow port 1156.
So i'm unsure why this isn't working, Any help would be much appreciated!
31 Answer
You have to edit the file under
sudo vim /etc/postgresql/9.3/main/pg_hba.confAnd Press SHIFT+G Now change md5 to trust in the below line
host all all 127.0.0.1/32 md5to
host all all 127.0.0.1/32 trustIf you need to listen from any IP address we have to edit the file under
sudo vim /etc/postgresql/9.3/main/postgresql.confAnd search for localhost and uncomment the below line
listen_addresses = 'localhost'And change * localhost to *
listen_addresses = '*'If you need login postgres User you have to do the below settings
Edit the file
sudo vim /etc/postgresql/9.3/main/pg_hba.confPress SHIFT + G to reach the bottom of the file
And change the md5 to trust
local all postgres md5to
local all postgres trustThen save the changes and exit by wq!
Then restart the server using
sudo service postgresql restartNote:> Here i'am using PostgreSQL version 9.3, In you environment it may change according to you choose the version.