[SOLVED] Flow CLI command DB access fails in JailKit environment: No access to mysqld.sock

Hello, wonderful people of the internet :slight_smile:

I am still quite new to Neos, but I am getting to a point, where I can work with it reasonably well. However, I encountered a problem with which I require a bit of outside help:

My setup:
My current Neos project has a custom command controller, that uses some components injected via @Flow\Inject, like NodeSearchService and NodeDataRepository. The command provided by this controller syncs some nodes from a different server via a REST API. For every piece of content fetched from the other server, I create a new content node or update an already existing one.
The local development version runs in a local web server, while the LIVE version runs on a shared server, where I have a shell user that is placed inside a JailKit environment.
Running the command locally works just fine and the command also does excactly what it is supposed to do.

My problem:
Running the command on the LIVE system with the line FLOW_CONTEXT=Production/Live php5 flow <myCustomCommand> produces the following error output:

An exception occured in driver: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

  Type: Doctrine\DBAL\Exception\ConnectionException
  File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriv
  Line: 103

Nested exception:
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

  Type: Doctrine\DBAL\Driver\PDOException
  Code: 2002
  File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php
  Line: 47

Nested exception:
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

  Type: PDOException
  Code: 2002
  File: Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php
  Line: 43

As I understand it, the JailKit environment does not allow direct access to the MySql socket. When asked, the server provider made clear that the JailKit environment will not be changed under any circumstances. The only information I got from the provider support was that I instead should connect to the database via IP and (quote) “use the option -H”, without specifying what program/script would need this option.

  • php5 has a -H option, but it is not related to this problem.
  • the flow script does not seem to have this option.

I really don’t know what to do here anymore. Did anyone run into this problem before? Any idea on how I can get the system to use an IP-based database connection when a command is called from the CLI?

Thanks for any replies <3

Hello Stefan,

i do’nt know jailKit at all but i think the answer from your hoster refers to the mysql command line options.

see here http://dev.mysql.com/doc/refman/5.7/en/mysql-command-options.html

–host=host_name, -h host_name
Connect to the MySQL server on the given host.

Did you try to use as mysql-hostname in your flow-configuration?

Regards, Martin

As Martin said.

localhost and differ in that one uses socket while the other uses tcp.

You could even configure an additional (sub-) context to be used on CLI that connects via tcp, if you fear speed issues changing it.

Cool, changing the host in the configuration to works.
I was not aware of the distinction between localhost and My assumption was that they have the exact same effect. Derp :smiley:

Thanks for your help, @mficzel and @christianm; you are awesome <3