php mysql localhost,127.0.0.1和ip区别
时间:2024-05-09 16:42:18 来源:未知 作者:站长技术网 点击:次
一家之言: localhost与127.0.0.1的区别 no1: localhost也叫local ,正确的解释是:本地服务器 no2: localhot(local)是不经网卡传输!这点很重要,它不受网络防火墙和网卡相关的的限制。 一般设置程序时本地服务用localhost是最好的,localhost不会解析成ip,也不会占用网卡、网络资源。 有时候用localhost可以,但用127.0.0.1就不可以的情况就是在于此。猜想localhost访问时,系统带的本机当前用户的权限去访问,而用ip的时候,等于本机是通过网络再去访问本机,可能涉及到网络用户的权限。 他家之言: 1. mysql -h 127.0.0.1 的时候,使用TCP/IP连接, 2. mysql -h localhost 的时候,是不使用TCP/IP连接的,而使用Unix socket; 3. mysql权限管理中的"localhost"有特定含义: 注意:虽然两者连接方式有区别,但当localhost 为默认的127.0.0.1时,两种连接方式使用的权限记录都是以下的1.row的记录(因为记录在前,先被匹配) *************************** 1. row *************************** *************************** 2. row *************************** 证明:
Current user: root@127.0.0.1 SSL: Not in use shell> mysql -h locahost Current user: root@localhost shell> mysql -h XXXX(ip) mysql> status; Current user: root@ip SSL: Not in use |