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
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
- Follow-Ups:
- Re: Weird issue with PHP and MySQL
- From: Richard
- Re: Weird issue with PHP and MySQL
- Prev by Date: Re: Solaris 10 compile of php-5.6.x fails during make, using Oracle Studio 12
- Next by Date: Re: Weird issue with PHP and MySQL
- Previous by thread: PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) in Unknown on line 0
- Next by thread: Re: Weird issue with PHP and MySQL
- Index(es):