MySQL相关文件——套接字文件

MySQL有两种主要的连接方式:

常用的还是TCP连接:

[root@mysql8 data]# mysql -h 192.168.103.67 -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.15 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

另外的一种方式就是这种unix socket的连接。在速度上比用tcp的方式更快,但只适用于mysql和应用同在一台PC上,依靠本地的.sock文件。如果不在同一台PC上,就没有办法连接了。

查看本地socket文件位置:
mysql> show variables like 'socket'\G
*************************** 1. row ***************************
Variable_name: socket
        Value: /data/mysql/mysql_3306/tmp/mysql_3306.sock
1 row in set (0.01 sec)

猜你喜欢

转载自blog.csdn.net/qq_43250333/article/details/109465759