|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-03-28 06:25 UTC] krakjoe@php.net
-Status: Open
+Status: Not a bug
[2016-03-28 06:25 UTC] krakjoe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 13:00:01 2025 UTC |
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