1. Client and server models

1) Data is a typical C/S Structural Services

1.mysql Native Client Tools
mysql
mysqladmin
mysqldump
3.mysql It's a binary program , Background daemon
Single process
Multithreading 

2)mysql Mode of connection

1.TCP/IP Connect
2.socket Connect
#tcp/ip Connect
mysql -uroot -p -h127.0.0.1
mysql -uroot -p -h127.0.0.1 -S /tmp/mysql.sock
#socket Connect
mysql -uroot -p -hlocalhost
mysql -uroot -p
# Be careful :
1) not always -h Namely TCP/IP Connect , If it is localhosts Namely socket Connect
2)socket Connection ratio TCP/IP Fast connection ,TCP/IP The connection requires three handshakes , Four waves , slow
3)socket The connection can only be local , Remote cannot be used 

2.MySQL Service composition

1) What are examples

1.MySQL The background process of  +  Threads  +  Pre allocated memory space
2.MySQL The background daemons will be started during startup , And generate worker threads , Pre allocated memory structure for MySQL Processing data usage .

Pre allocated memory , For example, the distribution of 8G To the database , So when the database starts, it takes up 8G Of memory space , But the memory occupied by more than will not be opened .

2.MySQL The service program consists of

1) adjoining course

1. Verify user identity , Determine user name and password
2. There are two ways to connect
- sockect  Connect
- TCP/IP  Connect
3. And SQL Layer to establish interactive threads 

2)sql layer

1. Receive data from the connection layer
2. Judge sql Sentence syntax
3. Judge SQL The semantics of the statement
4. Parser : analysis sql sentence , Generate execution plan
5. Optimizer : Choose the best plan in the execution plan
6. actuator : analysis sql sentence , Generate execution plan
6.1  Interact with the storage engine layer
6.2  What will be executed after optimization SQL To the storage engine layer
7. Record the cache , If the front end has redis, Cache data to redis
8. Log 

3) Storage engine layer

1. And sql Layer to establish interaction , receive SQL It's coming from layers SQL sentence
2. Interact with disk , get data , Return data to sql layer