Search This Blog

Sunday, November 18, 2018

Forcing a particular transport to MySQL


To ensure that the client makes a TCP/IP connection to the local server, use --host or -h to specify a host name value of 127.0.0.1, or the IP address or name of the local server. You can also specify the connection protocol explicitly, even for localhost, by using the --protocol=TCP option. For example:

shell> mysql --host=127.0.0.1
shell> mysql --protocol=TCP
The --protocol={TCP|SOCKET|PIPE|MEMORY} option explicitly specifies a protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. For example, connections on Unix to localhost are made using a Unix socket file by default:

shell> mysql --host=localhost
To force a TCP/IP connection to be used instead, specify a --protocol option:

shell> mysql --host=localhost --protocol=TCP
Protocol types:
TCP: TCP/IP connection to local or remote server. Available on all platforms.
SOCKET: Unix socket file connection to local server. Available on unix only.
PIPE: Named-pipe connection to local or remote server. Available on windows only.
MEMORY: Shared-memory connection to local server. Available on windows only.
A Unix socket file connection is faster than TCP/IP, but can be used only when connecting to a server on the same computer.