史上最详细的Mysql用户权原理和实战,生产案例
1. 访问控制
1.1 连接验证(阶段一)
当连接到MySQL时,根据以下条件接受或拒绝连接:
- 通过提供正确的密码来验证身份
- 账户是否锁定
服务器首先检查凭据,然后检查帐户锁定状态。任一步骤失败都会导致拒绝访问。没有问题就接受连接。
锁定状态记录在user表 account_locked列中。
1.2 允许的连接
表显示了如何将各种的组合 User和Host值在 user表适用于传入的连接。
User | Host | 允许的连接 |
---|---|---|
fred | h1.example.net | 来自 h1.example.net的red |
‘’ | ‘h1.example.net’ | 来自 h1.example.net的任何用户 |
‘fred’ | ‘%’ | 任何主机的fred连接 |
‘’ | ‘%’ | 从任何主机连接的任何用户 |
‘fred’ | ‘%.example.net’ | 从example.net域中任何主机的fred进行连接 |
‘fred’ | ‘x.example.%’ | fred,从连接 x.example.net, x.example.com, x.example.edu等 |
‘fred’ | ‘198.51.100.177’ | 从IP:198 |