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

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

王林
Release: 2023-09-20 18:53:06
forward
1009 people have browsed it

如何强制 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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template