MySQL数据库的套接字文件和pid文件
socket文件:当用Unix域套接字方式进行连接时需要的文件。
pid文件:MySQL实例的进程ID文件。
MySQL表结构文件:用来存放MySQL表结构定义文件。
套接字文件
Unix系统下本地连接MySQL可以采用Unix域套接字方式,这种方式需要一个套接字(socket)文件。套接字文件可由参数socket控制。一般在/tmp目录下,名为mysql.sock:
show variables like 'socket'\G

|
mysql有两种连接方式,常用的一般是tcp mysql -h(ip) -uroot -pxxx #常用的 mysql -S /tmp/mysqld.sock MySQL 采用unix socket连接方式,比用tcp的方式更快,但只适用于mysql和应用同在一台PC上。如果不在同一台pc上,就没有办法连接了。
|
socket文件类似于管道,但它是在网络上面工作的。您到计算机就是靠它来做网络处理的。您可能听说过“Winsock”,那是 Windows 的套接口。我们在这里不深入谈有关套接口,因为如果您不写程序,您不会用到它,但如果您看到您系统里有个文件类型是s,您知道它是什么就行了。
比如说mysql 运行的时候通常会产生一个socket文件。
[root@yaoyao tmp]# ls -l /tmp/mysql.sock
srwxrwxrwx 1 mysql mysql 08月 7 10:03 mysql.sock
/tmp目录下还有一些socket文件,多半是运行Xwindows的时候产生的。
|
linux、unix这种系统认为io、设备等等都是文件,socket也是io https://en.wikipedia.org/wiki/Unix_domain_socket A Unix domain socket or IPC socket (inter-process communication socket) is a data communications endpoint for exchanging data between processes executing on the same host operating system. Like named pipes, Unix domain sockets support transmission of a reliable stream of bytes (SOCK_STREAM, compare to TCP). In addition, they support ordered and reliable transmission of datagrams (SOCK_SEQPACKET, compare to SCTP), or unordered and unreliable transmission of datagrams (SOCK_DGRAM, compare to UDP). The Unix domain socket facility is a standard component of POSIX operating systems. The API for Unix domain sockets is similar to that of an Internet socket, but rather than using an underlying network protocol, all communication occurs entirely within the operating system kernel. Unix domain sockets use the file system as their address name space. Processes reference Unix domain sockets as file system inodes, so two processes can communicate by opening the same socket. In addition to sending data, processes may send file descriptors across a Unix domain socket connection using the sendmsg() and recvmsg() system calls. This allows the sending processes to grant the receiving process access to a file descriptor for which the receiving process otherwise does not have access.[1] This can be used to implement a rudimentary form of capability-based security.[2] For example, this allows the Clam AntiVirus scanner to run as an unprivilegeddaemon on Linux and BSD, yet still read any file sent to the daemon's Unix domain socket. |
pid文件
当MySQL实例启动时,会将自己的进程ID写入一个文件中——该文件即为pid文件。该文件可由参数pid_file控制。默认路径位于数据库目录下,文件名为主机名.pid。
show variables like 'pid_file'\G

MySQL表结构文件
因为MySQL插件式存储引擎的体系结构的关系,MySQL对于数据的存储是按照表的,所以每个表都会有与之对应的文件(对比SQL Server是按照每个数据库下的所有表或索引都存在mdf文件中)。不论采用何种存储引擎,MySQL都有一个以frm为后缀名的文件,这个文件记录了该表的表结构定义。二进制文件。
frm还用来存放视图的定义,如我们创建了一个v_a视图,那么对应地会产生一个v_a.frm文件,用来记录视图的定义,该文件是文本文件,可以直接使用cat命令进行查看:
show variables like 'datadir';
exit
cd /usr/local/var/mysql/test
cat v_a.frm
TYPE=VIEW query=select 'test'.'a'.'b'AS'b'from'test'.'a' md5=4eda70387716a4d6c96f3042dd68b742
updatable=1 algorithm=0 definer_user=root
definer_host=localhost
suid=2 with_check_option=0 timestamp=2010-08-04 07:23:36 create-version=1 source=select*from a
client_cs_name=utf8
connection_cl_name=utf8_general_ci
view_body_utf8=select'test'.'a'.'b'AS'b'from'test'.'a'
About Me
.............................................................................................................................................
● 本文整理自网络
● 本文在itpub(http://blog.itpub.net/26736162/abstract/1/)、博客园(http://www.cnblogs.com/lhrbest)和个人微信公众号(xiaomaimiaolhr)上有同步更新
● 本文itpub地址:http://blog.itpub.net/26736162/abstract/1/
● 本文博客园地址:http://www.cnblogs.com/lhrbest
● 本文pdf版、个人简介及小麦苗云盘地址:http://blog.itpub.net/26736162/viewspace-1624453/
● 数据库笔试面试题库及解答:http://blog.itpub.net/26736162/viewspace-2134706/
● DBA宝典今日头条号地址:http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826
.............................................................................................................................................
● QQ群号:230161599(满)、618766405
● 微信群:可加我微信,我拉大家进群,非诚勿扰
● 联系我请加QQ好友(646634621),注明添加缘由
● 于 2017-08-01 09:00 ~ 2017-08-31 22:00 在魔都完成
● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
.............................................................................................................................................
● 小麦苗的微店:https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
● 小麦苗出版的数据库类丛书:http://blog.itpub.net/26736162/viewspace-2142121/
.............................................................................................................................................
使用微信客户端扫描下面的二维码来关注小麦苗的微信公众号(xiaomaimiaolhr)及QQ群(DBA宝典),学习最实用的数据库技术。
小麦苗的微信公众号 小麦苗的DBA宝典QQ群1 小麦苗的DBA宝典QQ群2 小麦苗的微店
.............................................................................................................................................
![]()
MySQL数据库的套接字文件和pid文件的更多相关文章
- MYSQL数据库的套接字文件,pid文件,表结构文件
socket文件:当用Unix域套接字方式进行连接时需要的文件. pid文件:MySQL实例的进程ID文件. MySQL表结构文件:用来存放MySQL表结构定义文件. 套接字文件 Unix系统下本地连 ...
- linux网络环境下socket套接字编程(UDP文件传输)
今天我们来介绍一下在linux网络环境下使用socket套接字实现两个进程下文件的上传,下载,和退出操作! 在socket套接字编程中,我们当然可以基于TCP的传输协议来进行传输,但是在文件的传输中, ...
- JDBC课程1-实现Driver接口连接mysql数据库、通用的数据库连接方法(使用文件jdbc.properties)
package day_18; import jdk.internal.util.xml.impl.Input; import org.junit.Test; import java.io.Input ...
- phpmyadmin error:#2002 - 服务器没有响应 (或者本地 MySQL 服务器的套接字没有正确配置)
1. 将 "phpMyAdmin/libraries"文件夹下的config.default.php文件中的$cfg['Servers'][$i]['host'] = 'local ...
- MySQL数据库~~~~~查询行(文件的内容)
1. 单表查询 语法 select distinct 字段 from 库名.表名 where 条件 group by 字段 # 分组 having 筛选 # 过滤 order by 字段 # 排序 l ...
- 安装mysql数据库出现错误"系统找不到指定文件"
http://blog.csdn.net/Marvel__Dead/article/details/63262641?locationNum=4&fps=1
- 用Socket套接字发送和接收文件(中间用数组存取)
创建服务端: public class TcpFileServer { public static void main(String[] args) throws Exception { //1创建S ...
- MySQL数据库出现The server quit without updating PID file.
一.服务器环境 操作系统:CentOS-6.4 服务器环境:集成环境LNMP1.0 二.步骤重现 1.安装LNMP1.0,具体操作方法见这里,安装成功: 2.因个人需求,现将MySQL数据库存放在/d ...
- MySQL技术内幕InnoDB存储引擎(三)——文件相关
构成MySQL数据库和InnoDB存储引擎表的文件类型有: 参数文件:MySQL实例运行时需要的参数就是存储在这里. 日志文件:用来记录MySQL实例对某种条件做出响应时写入的文件. socket文件 ...
随机推荐
- docker 容器容器之间网络通信 docker-compose.yaml 配置固定ip
1.创建自己的桥接网络 $ docker network create --subnet=172.18.0.0/16 mynetwork 2.docker-compose.yaml 文件格式demo ...
- 关于Git我们不得不知道的事(一)
一.什么是Git? Git是目前世界上最先进的分布式版本控制系统(没有之一). Git可以协助我们很方便的管理我们的项目,我们随时可以找回(或者回到)我们之前任何一个时刻的项目:还可以让同事或者开发小 ...
- django-rest-framework权限验证
django-rest-framework权限验证 在项目根目录下新建utils的文件 新建permissions.py from rest_framework.permissions import ...
- flask-include、set、with、模板继承
flask-include.set.with include: 跟django的include类似,将一个html的代码块直接嵌入另一个html文件中 {% include 'html ...
- PTA 6-1 单链表逆转
本题是一个非常经典的题目:单链表逆转. 这是链表结点的定义: typedef struct Node *PtrToNode; struct Node { ElementType Data; /* 存储 ...
- Python常见数据结构-Dictionary字典
字典基本特点 字典的每个键值 key=>value 对用冒号 : 分割,每个键值对之间用逗号 , 分割,整个字典包括在花括号 {} 中. 键是唯一的,如果重复最后的一个键值对会替换前面的,值不需 ...
- Python 1基础语法一(注释、行与缩进、多行语句、空行和代码组)
一.注释Python中单行注释以 # 开头,实例如下: # 第一个注释 print ("Hello, Python!") # 第二个注释 输出结果为: ============== ...
- "按钮"组件:<h-button> —— 快应用组件库H-UI
 <import name="h-button" src="../Common/ui/h-ui/basic/c_button"></impo ...
- 外观模式(c++实现)
外观模式 目录 外观模式 模式定义 模式动机 UML类图 源码实现 优点 缺点 模式定义 外观模式(Facade),为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一子 ...
- Linux c++ vim环境搭建系列(1)——Ubuntu18.04.4编译安装vim8.2
1. vim源码编译安装 参考网址: https://github.com/ycm-core/YouCompleteMe/wiki/Building-Vim-from-source 安装各类依赖库 s ...





