Home  >  Article  >  Database  >  How to force MySQL to connect via TCP instead of Unix socket?

How to force MySQL to connect via TCP instead of Unix socket?

王林
王林forward
2023-09-20 18:53:06958browse

如何强制 MySQL 通过 TCP 而不是 Unix 套接字连接?

Programs such as mysql and mysqldump using the MySQL client library support connecting MySQL to server files and naming through multiple transmission protocols (such as TCP/IP, Unix sockets) Pipes, shared memory, etc.

For a given connection, if no transport protocol is specified, it is identified as a separate task.

Example

A connection to localhost will result in a socket file connection on Unix and Unix-like systems, otherwise a TCP/IP connection to 127.0.0.1. If a protocol must be specified specifically, this can be done using the --protocol command option.

The following table shows the allowed values ​​for --protocol and tells the platform where each value applies. Note that these values ​​are not case-sensitive.

##PIPENamed PipesWindowsMemoryShared MemoryWindows
--Protocol value Transmission protocol used Applicable platform
TCP TCP/IP All
SOCKET Unix Socket File Unix and Unix-like systems
TCP/IP transport is also supported for connecting to local or remote MySQL servers. Socket files, named pipes, and shared memory transfers are only supported for connections to the local MySQL server. It should be noted that named pipe transport does allow remote connections, but this feature is not currently implemented in MySQL.

Transport protocol - not specified

If no transport protocol has been specified, localhost is interpreted as -

  • On Unix and Unix-like systems, to A connection to localhost results in a socket-file connection.

  • On other systems, a connection to localhost results in a TCP/IP connection to 127.0.0.1.

Transport Protocol - Specify

If a transport protocol is specified, localhost is interpreted according to that specific protocol.

The above is the detailed content of How to force MySQL to connect via TCP instead of Unix socket?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete