Programs such as ‘mysql’ and ‘mysqldump’, that use MySQL client library have the support of MySQL connection to server with the help of many transport protocols, such as TCP/IP, Unix socket file, named pipe, shared memory, and so on.
With respect to a given connection, if the transport protocol is not specified, it is determined as a separate task.
Example
Connections to localhost will result in a socket file connection on Unix and Unix-like systems, and a TCP/IP connection to 127.0.0.1 otherwise. If the protocol has to be specified in particular, it is done using the --protocol command option.
The below table shows the values permitted for --protocol and also tells the platforms where each of these values are applicable. It is to be noted that the values are not case-sensitive.
--protocol value | Transport protocol used | Applicable platforms |
---|---|---|
TCP | TCP/IP | All |
SOCKET | Unix socket file | Unix and Unix-like systems |
PIPE | Named pipe | Windows |
MEMORY | Shared memory | Windows |
TCP/IP transport supports connections to local or remote MySQL servers too. Socket-file, namedpipe, and shared-memory transports only support connections to local MySQL servers. It is to be noted that named-pipe transport does allow for remote connections, but this ability hasn’t been implemented in MySQL as of now.
Transport Protocol – Not Specified
If the transport protocol hasn’t been specified, then localhost is interpreted as −
On Unix and Unix-like systems, a connection to the localhost results in a socket-file connection.
On other systems, a connection to the localhost results in a TCP/IP connection to 127.0.0.1.
Transport Protocol – Specified
If the transport protocol is specified, then the localhost is interpreted based on that specific protocol.