0

I just compiled PHP 7.0.4 on a Fedora 23 box, created a test script to connect to MySQL on localhost and all I get is:

Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: No such file or directory

According to PHP that is because PHP cannot find /tmp/mysql.sock, the file does exist, so I reconfigured MySQL and PHP to have them both point to the same file, without success, this is what /tmp shows about mysql.sock:

lrwxrwxrwx   1 root  root    25 Mar 21 10:13 mysql.sock -> /var/lib/mysql/mysql.sock

I don't know what to do at this point, because when I change the script to connect to 127.0.0.1, it works just fine.

Others at stackoverflow told me to post this here to see if I can get more help, because there is nothing wrong with the code I'm using to connect. (Related Question: https://stackoverflow.com/questions/36065587/php-not-seeing-mysql-sock-from-the-web)

Finally, my Firewall is masked and my selinux is disabled and I also tested it from the console and it works, it doesn't work only via web even though phpinfo() shows this.

mysqli.default_socket   /tmp/mysql.sock /tmp/mysql.sock
  • Could you do a dig localhost and post results? – hub Mar 21 '16 at 14:41
  • so I reconfigured MySQL and PHP to have them both point to the same file. Can you post both php.ini and my.cnf? – GregL Mar 21 '16 at 14:50
  • my.cnf has this: "socket=/var/lib/mysql/mysql.sock" and php.ini has this: "mysqli.default_socket = /tmp/mysql.sock" also my mysqld.service has "PrivateTmp=false" – jfha73 Mar 21 '16 at 15:03
  • dig localhost showed me this: "localhost. 600 IN A 127.0.0.1" – jfha73 Mar 21 '16 at 15:03
  • Use strace on the process and see what happens. – Florin Asăvoaie Mar 21 '16 at 16:00
0

It turned out when I built PHP I did not include --with-mysql-sock=/path/to/mysq.sock, so even though it was set in php.ini it did not know where to find it, once I included that it worked.

Thanks for your help everybody.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.