Weird issue with PHP and MySQL
| From: | Jorge Hernandez | Date: | Fri, 18 Mar 2016 13:58:47 +0000 |
| Subject: | Weird issue with PHP and MySQL | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-20469@lists.php.net to get a copy of this message | ||
Hey guys,
I just compiled and installed PHP 7.0.4 on my Fedora 23, created a test
script to connect to MySQL in localhost, but all I'm getting is:
Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error:
No such file or directory
I found that is caused because PHP cannot find mysql.sock in the defined
path, so I created a symbolic link in /tmp to it and changed
mysqli.default_socket in php.ini to /tmp/mysql.sock, restarted both mysql
and apache but it keeps showing the same.
Here is the weird part:
When I run the same script via CLI it runs just fine, just not via web, if
I change localhost for 127.0.0.1, it works.
I made sure that 127.0.0.1 is set to localhost in /etc/hosts, but it just
doesn't make any sense, if php (the command) gets it right, why not the
apache module? somebody asked me if they were reading the same php.ini and
they are, phpinfo() shows me that the module is reading the file I put the
path in and php (the command) shows: mysqli.default_socket =>
/tmp/mysql.sock => /tmp/mysql.sock
So if they both are configured the same, why one does connect, but not the
other one?
Thanks,
--
=============
Jorge Hernandez