Connect phpStorm to Local "Lightning" database without supporting socket

How can I connect phpStorm to Local “Lightning” database without supporting socket?

phpStorm does not support socket connection. I need a port and I can’t find it in Local anymore.

Thanks!

1 Like

The port is in the same Database tab as always. Is it gone for you? :thinking: I just configured a DB using phpStorm and the Local DB with port 10011.

imagen

imagen

1 Like

Yes. In the new “Lightning” version, the port info is gone. Only the socket path is available. I can’t use port anymore.

1 Like

I don’t see the port either, but I opened Adminer on the Database tab, and it showed it me the port in the URL:

http://localhost:10015/?username=root&db=local

Yes but still does not connect using the URL port.

Lost connection to MySQL server at ‘waiting for initial communication packet’, system error: 60

Looks like socket is the only current way of connection and phpStorm does not support socket connection.

:confused:

2 Likes

Yes. I haven’t gotten it to connect either. I was hoping showing the port would get it working for somebody else…

Same thing happening for me - phpStorm tries to connect but can’t

2 Likes

Any news over here? I’m facing the same issue while scaffolding a Chisel Project. I guess you need to pass your external IP instead. But then i get an ER_HOST_NOT_PRIVILEGED

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Hey everyone, sorry for the confusion with this.

The way to connect to the DB depends on the OS that you are using. Macs use sockets, while Windows uses ports. This is because sockets are more performant, but Windows doesn’t support unix sockets.

For those of you using Mac – it looks like there is this project to bring Unix sockets to Java:

https://kohlschutter.github.io/junixsocket/quickstart.html

Maybe you can use that code? I found that project by reading through the steps from this comment in PHPStorm’s Support site. It mentions DataGrip, but that’s part of the IntelliJ family, so maybe this will work for PHPStorm as well?

Download an up-to-date version of junixsocket GitHub - kohlschutter/junixsocket: Unix Domain Sockets in Java (AF_UNIX)

The Ubuntu package is currently 2.04, and did not work for me. The latest at time of writing (2.3.1) did work.

Extract junixsocket somewhere (doesn’t matter, just needs to be accessible to DataGrip.)

In DataGrip’s Data Sources and Drivers Window, select the MySQL driver. Under ‘Driver Files’, click the + button and select:

junixsocket-mysql-2.3.1.jar

junixsocket-core-2.3.1.jar

junixsocket-common-2.3.1.jar

junixsocket-native-common-2.3.1.jar

from wherever you extracted them.

Add a new MySQL datasource, and under ‘Advanced’:

set ‘socketFactory’ to ‘org.newsclub.net.mysql.AFUNIXDatabaseSocketFactory’

and add ‘junixsocket.file’ with the path to our unix socket.

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000070290/comments/360001349799

Local Flywheel used host IP + port for the database server. Local Lightning uses a socket.

I was able to get the socket running for local Codeception tests (.env files), but PhpStorm’s Database tool window cannot use a socket because Storm is written in Java and Java can’t use sockets, per their Storm’s support, which wrote this back to me:

MySQL JDBC driver only supports TCP/IP and - on Windows - named pipes to connect to the database. Please see https://lists.mysql.com/java/8749.
So please enable networking in your MySQL server and use ‘localhost’ with port for connection.

Additional references:

So, please advise – maybe ‘localhost’ is sufficient, like wp-config.php seems good with but I need a different port#???

2 Likes

@clay any idea how to get database a unique host+port per site to which PhpStorm could connect?

Also very interested in this question

@ben.turner or anyone else have any feedback or insights about this?

Hey @cliff – I reopened this topic, and moved your replies here.

Can you take a closer look at my reply above?

I don’t know if that will work, so if you can take a look and let us know if it works for you that would be great!

:man_facepalming:

After I did some more searching within the forums here, it looks like @clay wrote up an FAQ for this specific case:

Can you all take a look and see if that gets you what you need?

2 Likes

@ben.turner

Clay’s post did it for me! Yes! TyTyTy!

btw, PhpStorm’s “Test Connection” showed this warning/error:

I set it to UTC. Hopefully no issues in doing that. Wondering if Local should have done that itself (so is it a bug?)

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.

I don’t know if it’s a bug per se since timezone things can be so complicated and hyper specific to the environment and site, Local might have trouble getting things correct automatically.

I think this StackOverflow question and answer does a good job of outlining some of the things to consider related to MySQL timezones:

1 Like