Bug #71874 [Opn->Nab]: PHP cannot find mysql.sock file via web
| From: | krakjoe@php.net | Date: | Mon, 28 Mar 2016 06:26:01 +0000 |
| Subject: | Bug #71874 [Opn->Nab]: PHP cannot find mysql.sock file via web | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200174@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71874&edit=1
ID: 71874
Updated by: krakjoe@php.net
Reported by: jfha73 at gmail dot com
Summary: PHP cannot find mysql.sock file via web
-Status: Open
+Status: Not a bug
Type: Bug
Package: MySQLi related
Operating System: Fedora 23
PHP Version: 7.0.4
Block user comment: N
Private report: N
New Comment:
I am 99.99999998% sure that this is not a bug.
The CLI binary, and your web server binary (apache, fpm, or whatever) do not necessarily use the
same configuration file (php.ini), or settings as both can be configured independently of php.ini,
with SAPI specific (php-fpm.ini, php-apache.ini, etc), and server specific configuration methods.
If you can negotiate a connection in CLI, then there is no problem connecting to the server and you
are looking at a misconfiguration issue.
If I'm wrong, please do re-open the bug.
If you do reopen the bug, please include information about your web server, and maybe a screenshot
of the relevant parts of phpinfo output (as executed by the web server), showing your mysqli
configuration section.
Previous Comments:
------------------------------------------------------------------------
[2016-03-21 18:15:10] jfha73 at gmail dot com
Description:
------------
Hey guys,
I have a script trying to connect to a localhost database on mysql/mariadb but it gives me the error
that cannot file mysql.sock message via web, when I run it via console it runs just fine, when I do
a fsockopen("/tmp/mysql.sock", 3306); it opens it, but for some reason mysqli_connect
cannot open that file to connect to MySQL, please check why PHP is doing this.
NOTE: it does work when run via console, just not the web, my firewall and selinux are both
disabled.
Test script:
---------------
<?php
$link = mysqli_connect("localhost", "root", "password",
"mysql");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The mysql database is gre$
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
?>
Expected result:
----------------
Show Success message.
Actual result:
--------------
Warning: mysqli_connect(): (HY000/2002): No such file or directory in /var/www/html/tests/mysql.php
on line 3
Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: No such file or directory
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71874&edit=1