Re: Weird issue with PHP and MySQL

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




> Date: Friday, March 18, 2016 09:58:47 -0400
> From: Jorge Hernandez <jfha73@xxxxxxxxx>
>
> 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,

How are you starting mysql and what is the real location of the
mysql.sock file? Also what are the permissions and ownership (user
and group) of the .sock file?

The users running a script via apache and a cli are different which
could cause issues if the .sock file has odd access settings.

Could you show both your IPv4 and v6 /etc/hosts entries for localhost.

   >  if I change localhost for 127.0.0.1, it works

so that we can see what you have there.





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