This is the 8th day of my participation in the Gwen Challenge in November. See details: The Last Gwen Challenge in 2021.


  • ๐Ÿ’ฌ if the article is helpful to you, welcome to pay attention to, like, collect (one key three even), have any questions welcome private letter, see will reply in time!

One, foreword

  • Hello everyone, I am a little honesty, front five “from 0 to 1 – fully understand MySQL” article to introduce how to install to a SQL database on the server need to experience the steps to parsing is complete, I believe you also have a preliminary understanding to the database, but as the saying goes “not to practice practice”, in front of the theory of knowledge is to learn Knowledge, somewhat boring, only in practice to master knowledge, so this article to introduce the client and the server side of the connection, the actual combat to complete the client and the server side of the connection, from the client to send instructions to the operation and access to the server response


  • Amway, recently often received some friend feedback problems, in order to facilitate communication, so the water created a group of friends communication, whether you have difficulty looking for a job, interview advice, or feeling a life want to find someone to talk to, can be in communication group of friends and water exchange, group of no great god, and small white distinguish only distributors and listeners, and group will often send some Welfare, welcome everyone to communicate, blow water, touch fish, progress (interested in private me or message)


  • “From 0 to 1- comprehensive and profound understanding of MySQL series” series of articles will continue to update, interested partners can follow me, together with cheer, progress together! , if it helps, don’t forget a key triple oh,แƒฆ(ยด แด— ยท ‘) than heart!


MySQL client vs. server


๐Ÿ… 2.1. C/S(client/server) architecture of MySQL


Speaking of MySQL architecture, namely can’t avoid referring to lick the dog and the goddess of the relationship between the, MySQL can be understood as by the client (lick the dog) and server (the goddess) in two parts, lick the dog (client) can be a variety of ways, when the goddess (server) “big aunt” to lick the dog (client) can be brown sugar water (such as mobile phone APP) , licking the dog when the goddess (server) is angry (client) can be a designer bag (e.g. computer software/web page).

Normally we execute a SQL flow, like licking the dog (client) to find a date with the goddess (server), probably through the following flow:

1, Licking dog (client) packaged their date information and attached to their own personal introduction and then sent to the goddess (server) such as: goddess, I am XX, tonight 7 o ‘clock in the woods to talk together, do you want to date?

2, goddess (server) received lick the dog (client) requests to date, carefully read the lick the dog (client) from the information, found that even lick the dog (client) to around the site to the woods, is surely what attempt, rather than direct refused to lick the dog date (like the client sends a request to fill in the wrong account or password, the server rejected the connection).

3, lick the dog (client) dating after being rejected by the goddess, unhappy all day, with the dormitory gay friends saw out a suggestion to it, let it change dating sites to a five-star hotel, so the goddess will allow its date, lick the dog listen to big, but it’s not so much money, reasoning, at last it male walked into the hospital sold a kidney to 5000 yuan Lick dog limped out of the men’s hospital, less than a kidney it obviously feel the body is not as good as before, but at the thought of the evening can date with the goddess, Lick dog face cracked a chrysanthemum-like smile.

4, lick the dog (client) repackaged their appointments, and then again to the goddess (server) launch date requests, goddess see dogs lick rendezvous is luxurious five-star hotels, rather than agreed date (like the client sends a request to fill in the correct account number or password, the server to accept connections)

5. Lick Dog was very happy to see the goddess accept its date request (establish a connection), and kept sending messages to the goddess (execute SQL), and the goddess server also replied to Lick Dog from time to time….


๐Ÿ‘2.2. MySQL client and server processes


In modern computers, a computer can run multiple programs, and each running program is called a process in the computer. The client/server architecture of MySQL is essentially two processes.

Each process on a computer has a unique says called the process ID, English name, PID, the process ID is randomly assigned by the computer, if the process is destroyed, this ID will be retrieved, the next time you run the system and will redistribute a PID to the process, to ensure that the same machine, the PID is only one time A.

The process name is determined by program design. The default MySQL server process name is mysqld, and the default MySQL client process name is MySQL.

In popular understanding, goddess (server) in order to appear more International, give yourself an English name :mysqld, Licking Dog (client) see goddess has such a good name, in order to attract the attention of the goddess, also give yourself an English name :mysql.

InterProcess Communication (IPC) : The transmission or exchange of information between different processes.

There are pipes (both anonymous and named pipes), message queues, semaphores, shared storage, sockets, Streams, and so on.


๐Ÿ“2.3, pick up girls big method one: TCP/IP


Since the last lick the dog (client) about the goddess (client) after successful, lick the dog (client) indescribably happy, wish time and goddess stick together, however, lick the dog (client) also know, if the goddess said offer her directly, and every time the goddess will certainly be more tired, and his only two kidneys, every time can’t think about the goddess of the time to sell the kidney Each time it wanted to invite the goddess, it would not directly declare its purpose, but first test the goddess with the trumpet, and then reveal its identity when the time was ripe. The steps were as follows:

๐Ÿ‘ถ Lick the Dog (client): Switch to trumpet 1 and send the goddess a message :” Hello?” “To test whether goddess (server) is available. If goddess replies, it indicates that goddess is available, and then proceed to the second step. If not, it is repeated to send.

๐Ÿ‘ถ Lick dog (client): “yes, what’s wrong?” , just send message soon lick the dog’s goddess (server) reply, see the news, lick the dog is very happy, it knows that the first step has been successfully, and it began the second step, goddess to send a message again: “hear,” support of love “movie premiere tonight, just roommates to two tickets (born in no friends.. “, but something can not go to the ticket to me, I a person also can not use two tickets, the rest of a ticket do not know what to do “, Lick dog know goddess most like Yang Mi, this movie is released she will go to see, goddess see the news will immediately reply to him.

๐Ÿ‘ฉ goddess (server): sure enough, goddess see this message immediately to lick dog (client) reply: “in fact, I super like Yang Mi, do not know the rest of a ticket can give me?” , the goddess is waiting for the licking dog (client) reply.

๐Ÿ‘ถ lick dog (client): Lick dog saw the goddess of the reply, the face of the chrysanthemum-like smile, but he clearly, can not perform too positive, so pretend to calm after a few minutes to the goddess reply: “good, that tonight at the school gate see you.”

๐Ÿ‘ถ lick dog (client): finally lick dog through their own way to success about the goddess, after watching the movie lick dog mood happy, happy to buy a bag of “orange” to roommates.

Licking dog (client) and successful date (connection) goddess (server), roommates are very surprised, have to ask him for advice, so he wrote his date goddess method to share a book to the dormitory single dog, the title of the book is: “A big method to pick up girls – three” temptation “. Kahn and Cerf are said to have been influenced by this book when they proposed TCP, IP, and the “three-wave” mechanism for establishing connections in TCP.

Take a look at how the lick dog met the goddess in pictures below:

๐Ÿ’… summary


MySQL -h host address -p port number (default is 3306) -u user name -p Press Enter (enter the password).

In a real business scenario, our application and the actual database are typically deployed on different servers, and to create a connection between them, it must be done over the network. In the public network environment, each computer has a unique IP address. MySQL uses the TCP/IP network architecture to communicate with other host processes in the network by IP address + port number.

Tip: TCP/IP network architecture is the most commonly used in the Internet architecture, it is a protocol cluster,TCP/IP protocol includes TCP, IP, UDP, ICMP and other protocols, rather than simply refers to THE TCP protocol and IP protocol, because TCP and IP two protocols occupy a very important role in this architecture, so This naming.


๐Ÿ‰2.4. Method two: shared memory


Lick the dog (client) found that using TCP/IP mode and goddess (server) are tried in several times before the launch date request, however, gradually, the goddess of responsive to him again, and he knew that use the same way for a long time the goddess got tired, so he and the goddess of girlfriends about, finally found a special habit, goddess is 4 in the morning After her morning run, she went to a breakfast shop to have breakfast. This habit was unbreakable, and the goddess persisted for two years.

Lick the dog know your opportunity again, so he gets up at half past three every day, and then went to the playground waiting for the goddess to running in the morning, to pretend that he “met”, thus the chance and the goddess alone, sure enough, the goddess see lick the dog after feel very surprised that someone and they have the same habit, so very interested in and lick the dog chatted, after running in the morning also I had breakfast with Lick Dog.

Sweet time is always short, with the goddess ate breakfast and then went back to the dormitory, because dogs lick the cause of the usual seldom exercise, get up and running at half past 3 is a very big challenge, he felt the body is going to fall apart, but lie in bed for recall the today with the goddess of intravenous drip, he think it is worth, he picked up a notebook, summed up the experience of today, note is called: How to Pick up Women: Creating a Space for Two

Here are some steps and pictures to see how licking the dog met the goddess through shared memory:

๐Ÿค1. When the MySQL server starts, specify –shared-memory to support shared memory.

๐Ÿน2. Specify –protocol=memory when the client connects to explicitly specify the use of shared memory for communication.




๐Ÿ’… summary


Shared memory is actually allows multiple processes to share a piece of storage space, any process on this space were modified, other processes are aware, the use of this way of communication, to avoid the data replication process between programs, data is written to the memory directly, reduced the number of copies, to improve the speed of communication, so the Shared memory is also known as IPC One of the fastest forms of communication.

The life cycle of shared memory is the same as that of the kernel. Even if all processes accessing shared memory have completed, the shared memory region object still exists (unless deleted by display), and any rewriting of the shared memory region object is retained until the kernel is reloaded and booted.

However, there is no synchronization or mutual exclusion mechanism in the shared memory, and multiple processes can modify the shared memory at the same time, which may lead to data security problems. Therefore, in order to ensure the data security in the shared memory area, we can use the semaphore to realize the synchronous access mechanism to the shared memory.


๐ŸŠ2.5, method three: named pipeline


Is the so-called “human unpleasant things nine times out of ten,” has just come to lick the dog use “Shared memory” goddess of way and to establish a proprietary private space, but I didn’t expect that the goddess became ill a few days later, can’t continue running in the morning, lick the dog is very want to see the goddess understand the specific situation, but contact the goddess has no news, can’t again to the goddess of the dormitory, reasoning, at last he thought of a A good way, that is to pay off the goddess of bestie, let bestie help her and goddess to establish exclusive connection.

Echocardiography, lick the dog immediately to the hospital to the rest of the also sold a kidney, got 5000 piece, he gave 3000 pieces to the goddess of girlfriends, asked her to help yourself and goddess to establish “communication channels”, every day will be their own little note to the goddess, and in this way, day after day, lick the dog let the goddess girlfriends pass a little note to goddess, etc. In the second month, finally I received a reply from the goddess, which read: “Thank you for caring for me during my illness. You are such a good person.”




Although the words are not many, but licking the dog is still very happy, their efforts finally received a return, so he picked up a notebook, recorded his time and goddess of the “dating experience “, the pen name is:” Pick up girls three big method – exclusive channel”

Here are some steps and pictures to see how licking the dog managed to reach the goddess through the naming pipeline:

๐Ÿค1. The –enable-named-pipe parameter is specified when the MySQL server is started.

๐Ÿน2. Specify the –protocol=pipe parameter when the client connects to explicitly specify the use of shared memory for communication.




๐Ÿ’… summary


A named pipe, also known as a FIFO file, is a special type of file that is assigned a name when it is created, and any process can open the other end of the pipe and communicate with the server process according to the given permissions. First input first Output (FIFO) follows the first-in, first-out (FIFO) principle, that is, the first incoming data is read out first.


Three, series of articles recommended


From 0 to 1- A Comprehensive and deep Understanding of MySQL series


Write in the last


At the end of the day, we don’t know how lick the Dog will end up in the story, but we do see lick’s efforts to date the goddess. This is not just as we struggle in life and work in reality? Although difficult, but still adhere to, salute in life every ordinary us!

Stick to the story to tell the knowledge, if you think the article is helpful to you, don’t forget to scan code attention and one button three link oh, your support is my motivation to create more high-quality articles.