-
socket 连接
由于 MySQL 是 C/S 模式
如果 client 和 server 在同一台主机,那么 client 连接 server 方式为 socket
通过以下命令进行连接,查看连接方式:
[liyajuan@localhost ~]$ mysql -uroot -p
(root@localhost)[mysql]> status;
--------------
mysql Ver 14.14 Distrib 5.7.34, for Linux (x86_64) using EditLine wrapper
Connection id: 34
Current database: mysql
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.34 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 1 day 2 hours 9 min 2 sec
-
TCP/IP 连接
当 client 和 server 不在同一主机上时,采用 TCP/IP 进行连接
(1) 连接方式如下:
mysql -h192.168.159.140 -udavid -p
终端连接方式
查看连接方式TCP/IP
(david@192.168.159.140)[(none)]> status;
--------------
mysql Ver 14.14 Distrib 5.7.34, for Linux (x86_64) using EditLine wrapper
Connection id: 36
Current database:
Current user: david@192.168.159.140
SSL: Cipher in use is ECDHE-RSA-AES128-GCM-SHA256
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.34 MySQL Community Server (GPL)
Protocol version: 10
Connection: 192.168.159.140 via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 1 day 2 hours 32 min 6 sec
(2) mysql workbench
(3) navicat