algorithmicCoder
algorithmicCoder

Reputation: 6789

Specifying protocol in mysql connect (PHP)

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

Upvotes: 6

Views: 6356

Answers (2)

Luke
Luke

Reputation: 1870

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

Upvotes: 1

deceze
deceze

Reputation: 522382

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

Upvotes: 13

Related Questions