Defining a protocol in mysql connect (PHP)

How do you define protocol = TCP in myql_connect ()?

+4
source share
2 answers

After reading the manual:

Whenever you specify "localhost" or "localhost: port" as the server, the MySQL client library will override this and try to connect to the local socket (named pipe in Windows). If you want to use TCP / IP, use "127.0.0.1" instead of "localhost".

http://www.php.net/manual/en/function.mysql-connect.php

+10
source

As far as I understand, mysql_connect() uses TCP / IP or a socket. It’s reliable what address you give him.

This is from the PHP manual.

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

http://php.net/manual/en/function.mysql-connect.php

+1
source

All Articles