webERP Forum
Database connection problem - Printable Version

+- webERP Forum (http://www.weberp.org/forum)
+-- Forum: webERP Discussion (http://www.weberp.org/forum/forumdisplay.php?fid=1)
+--- Forum: Installation Issues (http://www.weberp.org/forum/forumdisplay.php?fid=13)
+--- Thread: Database connection problem (/showthread.php?tid=8410)



Database connection problem - tomglare - 09-11-2020

Hello, having installed webERP, I was unable to log in - the result was always a message

"Connect failed: No such file or directory"

Eventually traced this to the initial mysqli_connect() call, where I put in some debugs to verify that this function was being passed the expected arguments, then suddenly remembered a previous problem I had with mysqli - the solution was to change config.php so that the host is specified not as 'localhost', but as '127.0.0.1'. I think this is something to do with the fact that I am using a non-standard port for the mySQL server; as a consequence, by specifying '127.0.0.1' it forces the function to actually use the port argument: otherwise it merrily ignores it and uses the socket instead.

There are probably other ways to solve the problem! Thought it was worth raising the matter in case anyone else encounters the isssue, or has a better way of resolving it.


RE: Database connection problem - TurboPT - 09-13-2020

Yes, I've seen a few others (not here, but elsewhere, such as stackoverflow as one example) about the localhost/127.0.0.1 difference with connectivity.

Not sure how/what makes the difference, many have claimed that it works using either one, so there must be configuration aspect somewhere.


RE: Database connection problem - falkoner - 09-13-2020

From http://pl.php.net/mysql_connect :

"Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as in your PHP configuration and leave the server field blank."

My understanding is that localhost and 127.0.0.1 are different. Using localhost the OS will use an internal socket to connect, but the PHP mysqli library will assume you are using the standard port. If you use 127.0.0.1 then you will use TCP/IP sockets as if it were an external server it was connecting to, and you can use any port.

Using localhost is quicker as the internal OS socket will be faster than the TCP/IP ones, but you cannot use it if you want to use a non standard port.

Hope I haven't just confused people more
Tim


RE: Database connection problem - TurboPT - 09-13-2020

That makes sense to me, thanks for the find, Tim.