连接

2017-02-23  本文已影响0人  xilongtao

连接注意

On Unix, MySQL programs treat the host name localhost
specially, in a way that is likely different from what you expect compared to other network-based programs. For connections to localhost
, MySQL programs attempt to connect to the local server by using a Unix socket file. This occurs even if a --port
or -P
option is given to specify a port number. 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:

翻译:
在unix系统上,mysql程序以一种并不是你期望的同其它基于网络编程不同方式的特殊对待localhost这个主机名称。对于localhost连接,mysql程序会企图去使用unix套接字文件去连接本地服务器。即使你使用了--posrt或者-P选项去指定了一个端口号也是如此。为了确保客户端使用TCP/IP连接本地服务器,你需要使用--host或者-h选项去制定一个主机名127.0.0.1或者这台主机的公网IP或者名称。如果在使用localhost主机名称的时候,你也可以使用--protocol=TCP选项来明确指定连接的协议名称。例如:

shell> mysql --host=127.0.0.1
shell> mysql --protocol=TCP

选项说明

上一篇 下一篇

猜你喜欢

热点阅读