Weird issue with PHP and MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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

[Index of Archives]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [Postgresql]     [PHP Books]     [PHP Databases]     [PHP SOAP]
  Powered by Linux