欢迎来到IDC91站长网!
解决服务器各种技术问题,加微信uecomzsr

MySQL

当前位置: IDC91 > 数据库 > MySQL

浅谈Mysql连接数据库时host和user的匹配规则

时间:2022-05-30 13:58:17|栏目:MySQL|点击:

--连接数据库时,host和user的匹配规则

官方文档:https://dev.mysql.com/doc/refman/5.7/en/connection-access.html

--host和user的匹配规则如下:

--是host为明确的最先匹配,host带%模糊的时候最后匹配,但host为''(空)位于%之后才匹配

--相同的host时候,比较user为明确的最先匹配,user为''(空)最后匹配

--相同的host和user时,排序是不确定的

When multiple matches are possible, the server must determine which of them to use. It resolves this issue as follows: 
Whenever the server reads the user table into memory, it sorts the rows. 
When a client attempts to connect, the server looks through the rows in sorted order. 
The server uses the first row that matches the client host name and user name. 
The server uses sorting rules that order rows with the most-specific Host values first. Literal host names and IP addresses are the most specific. (The specificity of a literal IP address is not affected by whether it has a netmask, so 198.51.100.13 and 198.51.100.0/255.255.255.0 are considered equally specific.) The pattern '%' means “any host” and is least specific. The empty string '' also means “any host” but sorts after '%'. Rows with the same Host value are ordered with the most-specific User values first (a blank User value means “any user” and is least specific). For rows with equally-specific Host and User values, the order is nondeterministic.

上一篇:Mysql InnoDB的锁定机制实例详解

栏    目:MySQL

下一篇:如何快速修改MySQL用户的host属性

本文标题:浅谈Mysql连接数据库时host和user的匹配规则

本文地址:https://idc91.com/shujuku/4041.html

广告投放 | 联系我们 | 免责申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

Copyright © 2023 IDC91.COM 版权所有晋ICP备17006296号