Weird issue with PHP and MySQL
[email protected] (Jorge Hernandez) Fri, 18 Mar 2016 09:58:47 -0400
| Newsgroups | php.install |
|---|---|
| Message-ID | <CAMSC_ze9YjyBpojqhGeSkG3kx4XNYTeUtNMOt++ESe1SLuCBkg@mail.gmail.com> |
--001a1143026e57045c052e532588 Content-Type: text/plain; charset=UTF-8 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 --001a1143026e57045c052e532588 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:verdana,= sans-serif">Hey guys,<br><br></div><div class=3D"gmail_default" style=3D"fo= nt-family:verdana,sans-serif">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:<br><br>Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: No such file or directory <br><br></div><div class=3D"gmail_default" style=3D"font-family:verdana,san= s-serif">I found that is caused because PHP cannot find mysql.sock in the d= efined 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 apac= he but it keeps showing the same.<br><br></div><div class=3D"gmail_default"= style=3D"font-family:verdana,sans-serif">Here is the weird part:<br><br></= div><div class=3D"gmail_default" style=3D"font-family:verdana,sans-serif">W= hen 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.<br><br></div><div class=3D"gmail= _default" style=3D"font-family:verdana,sans-serif">I made sure that 127.0.0= .1 is set to localhost in /etc/hosts, but it just doesn't make any sens= e, 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() show= s me that the module is reading the file I put the path in and php (the com= mand) shows: mysqli.default_socket =3D> /tmp/mysql.sock =3D> /tmp/mys= ql.sock<br><br></div><div class=3D"gmail_default" style=3D"font-family:verd= ana,sans-serif">So if they both are configured the same, why one does conne= ct, but not the other one?<br><br></div><div class=3D"gmail_default" style= =3D"font-family:verdana,sans-serif">Thanks,<br><br></div><div class=3D"gmai= l_default" style=3D"font-family:verdana,sans-serif"><br></div><br>-- <br><d= iv class=3D"gmail_signature"><br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br= >Jorge Hernandez<br></div> </div> --001a1143026e57045c052e532588--