Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing from MySQL "host" to "unix_socket" failed partially #9055

Closed
florisluiten opened this issue Oct 19, 2015 · 2 comments
Closed

Changing from MySQL "host" to "unix_socket" failed partially #9055

florisluiten opened this issue Oct 19, 2015 · 2 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Milestone

Comments

@florisluiten
Copy link
Contributor

I moved my MySQL server and decided to utilize unix_socket instead of specifying a hostname+port in my config.ini.php.

The tracker works fine when using unix_socket but the UI wouldn't use my "unix_socket" configuration. See the (simplyfied) version of my config.ini.php:

[database]
unix_socket = "/var/run/mysqld/mysqld.sock"
; host = "localhost"
; port = 3306
username = "piwik"
password = [... snip ...]
dbname = "piwik"
tables_prefix = "piwik_"
adapter = "MYSQLI"
charset = "utf8"
[... snip ...]

Apparently, the Tracker uses a different database connector and supports unix_socket. The libs/Zend/Db/Adapter/Mysqli.php does not support unix_socket and I receive a "could not connect" error when trying to login to Piwik (attempt to login to piwik@localhost).

The libs/Zend/Db/Adapter/Mysqli.php could easilly be patched to support unix_socket (which I did for now, but any update will probably mess this up). I guess a newer version of this library works out-of-the-box, but I'm not sure.

If any help is needed, I'm willing to write a patch for fixing the Adapter; just let me know what's best.

Piwik version 2.14.3 btw.

@mattab
Copy link
Member

mattab commented Nov 26, 2015

Hi @florisluiten thanks for the report. Is there maybe a way to fix this issue without touching the Zend files? ie. could we fix it in our own adapter?

Btw: It may work already (workaround) if you use PDO/MYSQL instead of MYSQLI in adapter ?

@florisluiten
Copy link
Contributor Author

Bonjour @mattab. Thank you for your answer. I've looked into the code to fix the issue without touching the Zend files, but was not able to so without fully reimplementing the _connect method. This seems to be an overkill for such a 'minor' problem.

I've therefore changed my adapter to PDO\MYSQL hoping that would solve the issue, but as I soon found out the PDO constructor is passed both the hostname+port as the unix_socket. As indicated in the PHP documenation (http://php.net/manual/en/ref.pdo-mysql.connection.php) either one should be passed, not both. Passing both did not work on my system.

The good news, this can easily be fixed in our own adapter. I've therefore created a PR #9298 to fix the particular problem. Hope this helps!

@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Nov 29, 2015
@tsteur tsteur added this to the 2.15.1 milestone Nov 29, 2015
@tsteur tsteur closed this as completed Nov 29, 2015
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Jan 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

No branches or pull requests

3 participants