Issues Connecting phpstorm to remote mysql server
I am using latest version of PHPStorm.
PhpStorm 2017.1.3
Build #PS-171.4424.11, built on April 26, 2017
Licensed to <removed>
You have a perpetual fallback license for this version
Subscription is active until August 22, 2018
JRE: 1.8.0_112-release-736-b21 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6
I am running a dev environment on a vagrant box with the project directory on my mac. This directory is mounted for the Ubuntu vagrant box. This has been working fine. The problem I am having is that when I try and configure a datasource for the IDE, I am getting error. (Connection refused to host: localhost; nested exception is: java.net.ConnectException: Operation timed out). Which seems erroneous as I am specifying a remote IP. (see below)
From the Mac terminal, I can execute a mysql to the remote box via: mysql -h 192.168.22.20 -u bogus -p bogus. This works like a champ, so this proves connectivity and appropriate permissions for the mysql user on the ubuntu VM.
For the datasource, I have:
- Host specified by IP :192.168.22.20.
- Database: bogus.
- user: bogus
- password is configured.
- The driver is set to MySQL
The URL looks like jdbc:mysql://192.168.22.20/bogus
So this leads me to the question as to why the connection error is specifying localhost and not the IP specified.
How Do I configure this to connect to the mysql server?
请先登录再写评论。
Hi there,
Are you using SSH tunnel? Makes sense if your MySQL is located on Vagrant-controlled VM... Maybe you did not set it up correctly then?
Some screenshots would be more than welcome to see.
Just in case: https://confluence.jetbrains.com/display/PhpStorm/Databases+and+SQL+Editor+in+PhpStorm
I did NOT set up an ssh tunnel as the VM has full IP connectivity to the host machine and vice-versa. I also tried port-forwarding from the VM to the host. Instead of using the std 3306 at the IP of the vm, I could use 127.0.0.1:33068. I tested via the command line and this too worked, but when I change the IDE datasource to this it failed as well.
I ran a sniffer (tcpdump) on the VM and there were NO connection attempts when trying to use phpStorm to connect to mysql. Just to verify, I ran mysql -h 192.168.22.20 -u bogus -p bogus I was able to connect to mysql and I saw the captured packets in tcpdump.
I then tried to connect to the port-forwarded address from the VM. The configuration has the vm forward port 3306 => 33068 on the host-machine. Again I was unable to connect to the database from the IDE, nor did I see any packets arrive into the packet-trace. Yet when I tried from the command-line it connects to mysql. (mysql -h 127.0.0.1 --port=33068 -u bogus -p bogus)
On a whim, I tried to connect to the host-machine's mysql server. This too failed. This leads me to believe there are problems with the mysql driver. Here are the screenshots: http://imgur.com/a/CJ0sb
>This leads me to believe there are problems with the mysql driver.
Downgrade driver then: http://stackoverflow.com/q/43604963/783119