mysql握手_mysql握手连接协议

本文详细介绍了MySQL连接的握手过程,包括服务端发送握手初始化包、客户端发送验证包和服务端发送成功包三个步骤。同时,重点解析了校验方法,说明了在mysql.user表中指定的认证方法以及通过抓包工具观察到的数据包内容,展示了如何确认和理解'plugin: mysql_native_password'字段的含义。
摘要由CSDN通过智能技术生成

建立MySql连接

a) 服务端往客户端发送握手初始化包(Handshake Initialization Packet)

b) 客户端往服务端发送验证包(Client Authentication Packet)

c) 服务端往客户端发送成功包

校验方法

在 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: N

Repl_slave_priv: N

Repl_client_priv: N

Create_view_priv: N

Show_view_priv: N

Create_routine_priv: N

Alter_routine_priv: N

Create_user_priv: N

Event_priv: N

Trigger_priv: Y

Create_tablespace_priv: N

ssl_type:

ssl_cipher:

x509_issuer:

x509_subject:

max_questions: 0

max_updates: 0

max_connections: 0

max_user_connections: 0

plugin: mysql_native_password

authentication_string:

password_expired: N

其中,plugin: mysql_native_password字段指定了应该使用什么校验方法。

抓包工具也可以看到

0000 02 00 00 00 45 00 00 86 59 22 40 00 40 06 00 00 ....E...Y"@.@... 0010 7f 00 00 01 7f 00 00 01 0c ea f0 fe b7 3c 39 4c .............<9L 0020 2e ac 31 1f 80 18 31 d7 fe 7a 00 00 01 01 08 0a ..1...1..z...... 0030 13 0f 4c 2f 13 0f 4c 2f 4e 00 00 00 0a 35 2e 36 ..L/..L/N....5.6 0040 2e 32 34 2d 6c 6f 67 00 03 00 00 00 2c 48 64 43 .24-log.....,HdC 0050 5e 33 22 4d 00 ff f7 08 02 00 7f 80 15 00 00 00 ^3"M............

0060 00 00 00 00 00 00 00 41 3a 42 7b 65 68 5d 75 57 .......A:B{eh]uW 0070 32 34 4f 00 6d 79 73 71 6c 5f 6e 61 74 69 76 65 24O.mysql_native 0080 5f 70 61 73 73 77 6f 72 64 00 _password.

最后,也会有mysql_native_password.

0818b9ca8b590ca3270a3433284dd417.png

客户端上传用户名、密码、当前数据库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值