Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database connection problem
09-13-2020, 07:16 AM,
#3
RE: Database connection problem
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
Reply


Messages In This Thread
Database connection problem - by tomglare - 09-11-2020, 01:46 AM
RE: Database connection problem - by TurboPT - 09-13-2020, 06:51 AM
RE: Database connection problem - by TimSchofield - 09-13-2020, 07:16 AM
RE: Database connection problem - by TurboPT - 09-13-2020, 09:26 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)