MySQL (InnoDB analysis): --- MySQL connection and communication mode (inter-process communication (pipe, socket, UNIX domain socket))

One, MySQL connection and communication method

  • When connecting to MySQL, it is a process of communication between a connection process and a MySQL database instance
  • The essence of communication is process communication
  • The ways of inter-process communication are : pipes, named pipes, shared memory, TCP/IP sockets, UNIX domain sockets, etc.

Two, TCP/IP socket connection

  • Between different machines , the client can use the mysql command to connect to the MySQL server. At this time, the TCP/IP socket is used.

Three, named pipes and shared memory

Named pipe

  • On Windows 2000, Windows XP, Windows 2003 and Windows Vista and above platforms, if two processes that require process communication are on the same server, you can use named pipes . The Microsoft SQL Server database is installed locally by default. The connection also uses named pipes
  • In the MySQL database, the --enable-named-pipe option must be enabled in the configuration file

Shared memory

  • In versions after MySQL 4.1, MySQL also provides a shared memory connection method, which is achieved by adding --shared-memory in the configuration file
  • If you want to use shared memory, when connecting, the MySQL client must also use the --protocol=memory option

Four, UNIX domain socket

  • UNIX domain sockets can only be used on one machine
  • The user can specify the path of the socket file in the configuration file , such as --socket=/tmp/mysql.sock

Demo case

  • View the location of the UNIX domain socket file

  • Exit the database, and then use the domain socket to connect to the database (when using the domain socket connection, you need to use the -S option to provide the UNIX domain socket file name, the -u option to provide the user name, the -p option to provide the user password,- I use mosaic to cover the p option)

Guess you like

Origin blog.csdn.net/m0_46405589/article/details/113844744