1.主机名不同的验证
问题:
当用户名相同,但主机名不同的多条记录。用户由不同主机登录时,选择使用那条记录来验证
编号 用户名 主机名
1 root localhost
2 root 127.0.0.1
3 root 192.168.141.239
4 root 192.168.141.241
5 root 192.168.%
6 root %
7 Root vm239
8 root ::1 #貌似没有什么用
结论:
于远程登录而言:
根据主机名或ip的详细程度来决定使用哪条记录验证
#如果同时存在完整的ip和hostname则还是使用ip?如果hostname比ip完整呢?
本机登录的选择方式:
if(host==''){ #如果没有指定主机名或ip
if exist(username,localhost){ #在数据库中存在该用户名的localhost主机记录
use this to login; #使用这条记录登录
}
eles if exist(username,ip){ #如果不存在localhost记录,查看是否存在对应的ip记录(不会选择127.0.0.1)
use this to login;
}
else 登录失败 #如果上述条件都不存在,则提示登录失败
}
if(host=='localhost'){ #如果指定主机名为localhost
if exist(username,localhost){ #则只使用localhost的记录验证,没有则登录失败
use this to login;
}
else 登录失败
}
if (host=='127.0.0.1'){ #如果指定主机名为127.0.0.1
if exist(user,localhost){ #如果存在localhost则用localhost登录
use this to login;
}
eles if exist(username,127.0.0.1){#如果不存在localhost则使用127.0.0.1登录
use this to login;
}
else 登录失败 #都不存在,则登录失败
}
if(host==hostname||host=ip){ #如果使用的是hostname或ip登录
if exist(username,ip){#则使用ip验证,不用hostname验证
use this to login;
}
#如果存在hostname记录而不存在ip记录,则是否用hostname登录?
else 登录失败 #如果不存在ip记录则登录失败
}
问题:
当用户名相同,但主机名不同的多条记录。用户由不同主机登录时,选择使用那条记录来验证
编号 用户名 主机名
1 root localhost
2 root 127.0.0.1
3 root 192.168.141.239
4 root 192.168.141.241
5 root 192.168.%
6 root %
7 Root vm239
8 root ::1 #貌似没有什么用
结论:
于远程登录而言:
根据主机名或ip的详细程度来决定使用哪条记录验证
#如果同时存在完整的ip和hostname则还是使用ip?如果hostname比ip完整呢?
本机登录的选择方式:
if(host==''){ #如果没有指定主机名或ip
if exist(username,localhost){ #在数据库中存在该用户名的localhost主机记录
use this to login; #使用这条记录登录
}
eles if exist(username,ip){ #如果不存在localhost记录,查看是否存在对应的ip记录(不会选择127.0.0.1)
use this to login;
}
else 登录失败 #如果上述条件都不存在,则提示登录失败
}
if(host=='localhost'){ #如果指定主机名为localhost
if exist(username,localhost){ #则只使用localhost的记录验证,没有则登录失败
use this to login;
}
else 登录失败
}
if (host=='127.0.0.1'){ #如果指定主机名为127.0.0.1
if exist(user,localhost){ #如果存在localhost则用localhost登录
use this to login;
}
eles if exist(username,127.0.0.1){#如果不存在localhost则使用127.0.0.1登录
use this to login;
}
else 登录失败 #都不存在,则登录失败
}
if(host==hostname||host=ip){ #如果使用的是hostname或ip登录
if exist(username,ip){#则使用ip验证,不用hostname验证
use this to login;
}
#如果存在hostname记录而不存在ip记录,则是否用hostname登录?
else 登录失败 #如果不存在ip记录则登录失败
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30126478/viewspace-1424199/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30126478/viewspace-1424199/