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 小麥苗的微店
.............................................................................................................................................
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2144037/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql之pid檔案MySql
- 資料庫檔案和檔案組資料庫
- MySql資料庫——檔案MySql資料庫
- oracle資料庫移動資料檔案、日誌檔案和控制檔案Oracle資料庫
- 建立資料庫檔案-日誌檔案-次要資料庫檔案資料庫
- mysql的資料檔案MySql
- mysql資料庫的檔案建立方式MySql資料庫
- 資料庫引數檔案控制檔案日誌檔案資料檔案跟蹤檔案等8大檔案的字典資料庫
- SQL Server 中資料庫檔案的存放方式,檔案和檔案組SQLServer資料庫
- mysql學習9:第四章:資料庫檔案--檔案MySql資料庫
- 資料檔案大小和資料庫的關係資料庫
- MySQL8.0.18資料庫新增資料檔案MySql資料庫
- Oracle 叢集的自啟動,OLR與套接字檔案Oracle
- Oracle資料檔案和臨時檔案的管理Oracle
- Oracle叢集技術 | OLR與套接字檔案(二)Oracle
- Mysql資料庫優化配置檔案my.ini檔案配置解釋MySql資料庫優化
- mysql學習7:第四章:資料庫檔案--引數檔案和型別MySql資料庫型別
- MySQL資料庫的frm、MYI、MYD檔案意義MySql資料庫
- 引數檔案控制檔案和資料檔案丟失的恢復
- MySQL資料庫中的日誌檔案---(4)配置日誌檔案輸出路徑MySql資料庫
- MySQL資料庫資料檔案路徑遷移步驟MySql資料庫
- Mysql資料庫配置檔案(my.ini)分析MySql資料庫
- git的gitignore檔案排除資料夾和檔案Git
- MYSQL資料檔案匯入MySql
- 還原sqlserver資料庫備份檔案.bak的檔案SQLServer資料庫
- mysql學習8:第四章:資料庫檔案--日誌檔案MySql資料庫
- oracle資料庫的配置檔案Oracle資料庫
- 資料庫檔案的遷移資料庫
- locate標頭檔案和庫檔案
- TCP套接字繫結雙埠傳輸檔案(python)TCPPython
- MySQL-02.MySQL的資料目錄和表檔案解析MySql
- MySQL資料庫中常見的日誌檔案彙總!MySql資料庫
- 表空間&資料檔案和控制檔案(zt)
- rename備庫資料檔案
- 在Oracle中移動資料檔案、控制檔案和日誌檔案Oracle
- 遠端備份資料庫和檔案的方法資料庫
- SQL Server 資料庫檔案的分離和附加SQLServer資料庫
- MySQL資料庫安裝,配置My.ini檔案MySql資料庫