当使用mysql -uroot -p -h272.16.1.51 登录数据库的时候,用的是TCP协议,用status命令查看:
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.6.38, for Linux (x86_64) using EditLine wrapper
Connection id: 10
Current database:
Current user: root@mysql03
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.38-log Source distribution
Protocol version: 10
Connection: 172.16.1.53 via TCP/IP
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 18 min 40 sec
而不加 h 的时候,是这样的:
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.6.38, for Linux (x86_64) using EditLine wrapper
Connection id: 11
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.38-log Source distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /application/mysql-5.6.38/tmp/mysql.sock
Uptime: 21 min 36 sec
是使用的UNIX socket,即UNIX套接字。