How to connect to mariadb via unix socket?

Answered

I would like to try the database tools included in PhpStorm but it surprisingly does not even let me connect to the mariadb demon via its socket at /run/mysqld/mysqld.sock (the CLI client works fine).

I only found some post for mysql suggesting using junixsocket, installed the recommended JARs as additional drivers and tried the JDBC URL
jdbc:mariadb:///test?socketFactory=org.newsclub.net.mysql.AFUNIXDatabaseSocketFactory&socket=/run/mysqld/mysqld.sock
but only got the most useless error message: "Connection is closed."

 

I also tried to use the mysql driver (also plus the junixsocket JARs) with the JDBC URL
jdbc:mysql:///test?socketFactory=org.newsclub.net.mysql.AFUNIXDatabaseSocketFactory&socket=/run/mysqld/mysqld.sock
but only got the following error:

[08S01] Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
java.net.SocketException: No such file or directory.

 

How does one connect to a mariadb instance in PhpStorm via a unix domain socket file?

2 comments
Comment actions Permalink

Here is instruction how to connect to MySQL via Unix socket.

If it does not help, please try the same steps but with latest Maria connector, also they say some third-party libraries are required. (JNA (net.java.dev.jna:jna) and JNA-PLATFORM (net.java.dev.jna:jna-platform) 4.2.1 or greater are also needed when you would like to connect to the server with Unix sockets or windows pipes.) JDBC URL could be like this - jdbc:mariadb://localhost:3306/revmgt?localSocket=/var/run/mysqld/mysqld.sock

1
Comment actions Permalink

I did not get it to work with the included or the newest MariaDB driver.
But with the JNA libs added and the advanced values enetered, it now works fine with the included MySQL driver.

Thanks for the pointers and please consider adding out-of-the-box unix domain socket support to the product.
Then other Linux users wouldn't need to jump through that hoops (we are way more spoiled by our all-inclusive repos, than the Windows folks which generally seem to like downloading and configuring drivers and tools themselves).

0

Please sign in to leave a comment.