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上,就没有办法连接了。

直接就用tcp方式mysql -h localhost -u root -proot直接登录了,没有用套接字这方式。由此也可看出不是必须。

 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

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文件的更多相关文章

  1. MYSQL数据库的套接字文件,pid文件,表结构文件

    socket文件:当用Unix域套接字方式进行连接时需要的文件. pid文件:MySQL实例的进程ID文件. MySQL表结构文件:用来存放MySQL表结构定义文件. 套接字文件 Unix系统下本地连 ...

  2. linux网络环境下socket套接字编程(UDP文件传输)

    今天我们来介绍一下在linux网络环境下使用socket套接字实现两个进程下文件的上传,下载,和退出操作! 在socket套接字编程中,我们当然可以基于TCP的传输协议来进行传输,但是在文件的传输中, ...

  3. JDBC课程1-实现Driver接口连接mysql数据库、通用的数据库连接方法(使用文件jdbc.properties)

    package day_18; import jdk.internal.util.xml.impl.Input; import org.junit.Test; import java.io.Input ...

  4. phpmyadmin error:#2002 - 服务器没有响应 (或者本地 MySQL 服务器的套接字没有正确配置)

    1. 将 "phpMyAdmin/libraries"文件夹下的config.default.php文件中的$cfg['Servers'][$i]['host'] = 'local ...

  5. MySQL数据库~~~~~查询行(文件的内容)

    1. 单表查询 语法 select distinct 字段 from 库名.表名 where 条件 group by 字段 # 分组 having 筛选 # 过滤 order by 字段 # 排序 l ...

  6. 安装mysql数据库出现错误"系统找不到指定文件"

    http://blog.csdn.net/Marvel__Dead/article/details/63262641?locationNum=4&fps=1

  7. 用Socket套接字发送和接收文件(中间用数组存取)

    创建服务端: public class TcpFileServer { public static void main(String[] args) throws Exception { //1创建S ...

  8. MySQL数据库出现The server quit without updating PID file.

    一.服务器环境 操作系统:CentOS-6.4 服务器环境:集成环境LNMP1.0 二.步骤重现 1.安装LNMP1.0,具体操作方法见这里,安装成功: 2.因个人需求,现将MySQL数据库存放在/d ...

  9. MySQL技术内幕InnoDB存储引擎(三)——文件相关

    构成MySQL数据库和InnoDB存储引擎表的文件类型有: 参数文件:MySQL实例运行时需要的参数就是存储在这里. 日志文件:用来记录MySQL实例对某种条件做出响应时写入的文件. socket文件 ...

随机推荐

  1. PHP获取当天、本周、本月、本季度、本年度时间

    function get_date($date, $t = 'd', $n = 0) { if ($t == 'd') { $firstday = date('Y-m-d 00:00:00', str ...

  2. Python爬虫系列(二):requests基础

    1.发送请求: import requests # 获取数据#r是一个 response 对象.包含请求返回的内容r = requests.get('https://github.com/timeli ...

  3. paste命令-合并文件

    paste [-s] [-d " "] [file1] [file2] -s:将文件合并成行 -d:显示时的分割符 //1.txt 1 6 2 7 3 8 4 9 5 10 //2 ...

  4. 【FreeMarker】【程序开发】数据模型,对象包装

    [FreeMarker][程序开发]数据模型,对象包装 分类: Java.FreeMarker2014-10-25 18:49 413人阅读 评论(0) 收藏 举报 FreeMarker   目录(? ...

  5. jmeter 信息头Bearer

    1.数据规则 2.登录时获取token信息 3.正则表达式获取token值 说明: (1)引用名称:下一个请求要引用的参数名称,如填写title,则可用${title}引用它. (2)正则表达式: ( ...

  6. AJ学IOS(40)UI之核心动画_抖动效果_CAKeyframeAnimation

    AJ分享,必须精品 效果: 效果一: 效果二: 代码: // // NYViewController.m // 图片抖动 // // Created by apple on 15-5-8. // Co ...

  7. CentOS7.5 使用Docker部署Jumpserver

    1.环境准备 # 查看系统版本 $ cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) # 查看内核版本 $ uname -a L ...

  8. threejs点击事件

    示例浏览地址:https://ithanmang.gitee.io/threejs/home/201807/20180703/02-raycasterDemo.html 双击鼠标左键选中模型并显示信息 ...

  9. 怎么用python 3 开发钉钉群机器人

    前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者:Python绿色通道 PS:如有需要Python学习资料的小伙伴可以加 ...

  10. stand up meeting 12-7

    weekend updates: 1.答题界面和结果界面的跳转和数据传输已全部完成. 2.答题界面完成简单的getRankingData API结果展示,答题时间,错误数目和错题题目的展示,点击题目可 ...