龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 数据库类 > MySQL 技术 >

MySQL远程访问设置终极方法(6)

时间:2014-12-03 12:39来源:网络整理 作者:网络 点击:
分享到:
复制代码 代码如下: mysql select user, host, password from user; +------------------+--------------------------+-------------------------------------------+ | user | host | password | +--------

复制代码 代码如下:

mysql> select user, host, password from user;
+------------------+--------------------------+-------------------------------------------+
| user             | host                     | password                                  |
+------------------+--------------------------+-------------------------------------------+
| root             | %                        | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root             | vagrant-ubuntu-trusty-64 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root             | 127.0.0.1                | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root             | ::1                      | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
|                  | localhost                |                                           |
|                  | vagrant-ubuntu-trusty-64 |                                           |
| debian-sys-maint | localhost                | *9B8E84CA988E1CA66CEB919A0D9D3BF1532942B6 |
+------------------+--------------------------+-------------------------------------------+
7 rows in set (0.00 sec)


可以看到数据库中有如上这些用户。那么,如果有'root'@'localhost'登录时,怎么匹配呢?

根据MySQL官方文档MySQL :: MySQL 5.6 Reference Manual :: 6.2.4 Access Control, Stage 1: Connection Verification里是如下面这样说的:

复制代码 代码如下:

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.

收藏文章
表情删除后不可恢复,是否删除
取消
确定
图片正在上传,请稍后...
评论内容为空!
还没有评论,快来抢沙发吧!
按钮 内容不能为空!
立刻说两句吧! 查看0条评论
精彩图集

赞助商链接