How do you specify pro开发者_开发问答tocol = TCP in myql_connect()?
By reading the manual:
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".
http://www.php.net/manual/en/function.mysql-connect.php
To my understanding mysql_connect()
uses TCP/IP or socket.
Dependable on what address you give it.
This is from PHP Manual
Note: 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.
http://php.net/manual/en/function.mysql-connect.php
精彩评论