mysql_connect localhost和127.0.0.1的区别(网络层阐述)
connects.php
mysql_connect('127.0.0.1','root','zzzizzz1'); mysql_connect('localhost','root','zzzizzz1');
使用strace获取系统调用:
stracephpconnects.php2>&1|grepconnect
#127.0.0.1->internetsocket connect(3,{sa_family=AF_INET,sin_port=htons(3306),sin_addr=inet_addr("127.0.0.1")},16)=-1EINPROGRESS(Operationnowinprogress) #localhost->unixdomainsocket connect(7,{sa_family=AF_FILE,path="/var/run/mysqld/mysqld.sock"},110)=0