Tiny Tiny RSS: Community

It is possible to use mysql via unix:socket instead of network?

Hi;

I have sereval services (nextcloud, matomo, wordpress) which works well by using
localhost:/tmp/mysqld/suck which us connecting to mysql via unix:socket instead of using the network.

While tiny tiny rss works fine when I connect to 127.0.0.1:3306
it simply refuse to connect when I try localhost:/tmp/mysqld/suck

I wonder if it is supported and/or how to do this ??

this is my config

grep "DB" ./ttrss/public_html/config.php
    define('DB_TYPE', 'mysql');
    define('DB_HOST', '');
    define('DB_USER', 'TTUSER');
    define('DB_NAME', 'TTDB');
    define('DB_PASS', 'PASSELEMOT);
    define('DB_PORT', '');

That’s a typo, yes? If not, I might have found your problem…

Short answer: no

You would probably need to extend the database classes in ./classes/db.php and ./classes/db/mysqli.php as the connect functions lack do not pass the socket option.

could you please give us a example, what i must change?

Does no one ever read (the docs)?

Untested! Use at your own risk!
Also be aware that any update may revert this.

In your config.php:

Set the DB_HOST to p:localhost and add a new entry like this:
define('DB_SOCKET', '/path/to/your/socket');

In ./classes/db.php change

$this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "");
to
$this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "", defined('DB_SOCKET') ? DB_SOCKET : "");

and finally in /classes/db/mysqli.php extend the connect function:

function connect($host, $user, $pass, $db, $port, $socket) {
    if ($port)
        $this->link = mysqli_connect($host, $user, $pass, $db, $port);
    else if ($socket)
        $this->link = mysqli_connect($host, $user, $pass, $db, NULL, $socket);
    else
        $this->link = mysqli_connect($host, $user, $pass, $db);

might be a typo but when I generate a socket for a service you choose the name and the directory
it could be /tmp/mysql/pouet too