1,建立MySql连接
a) 服务端往客户端发送握手初始化包(Handshake Initialization Packet)
b) 客户端往服务端发送验证包(Client Authentication Packet)
c) 服务端往客户端发送成功包
2,校验方法
在 a) 服务端往客户端发送握手初始化包(Handshake Initialization Packet),会携带客户端应该使用的authentication method.
每个用户使用什么样的校验方法是确定的,在mysql.user表中:Method used for authentication is tied to the user account and stored in the plugin column of mysql.user table.
mysql> select * from mysql.user where user = 'vddl' limit 10 \G;
*************************** 1. row ***************************
Host: localhost
User: vddl
Password: *57B4F32D94FF1EC6EC480F8F437B795BEE4A994F
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: N
Shutdown_priv: N
Process_priv: N
File_priv: N
Grant_priv: N
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: N
Super_priv: N
Create_tmp_table_priv: N
Lock_tables_priv: N
Execute_priv: