1. mysql -h 127.0.0.1 的时候,使用TCP/IP连接, mysql server 认为该连接来自于127.0.0.1或者是"localhost.localdomain"
2. mysql -h localhost 的时候,是不使用TCP/IP连接的,而使用Unix socket;此时,mysql server则认为该client是来自"localhost"
3. mysql权限管理中的"localhost"有特定含义:
当主机填写为127.0.0.1时mysql会采用tcp方式连接
mysql -h 127.0.0.1 mysql> status; Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.1.33-log Source distribution Protocol version: 10 Connection: 127.0.0.1 via TCP/IP
当主机填写为localhost时mysql会采用 unix domain socket连接
mysql -h locahost mysql> status; Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.1.33-log Source distribution Protocol version: 10 Connection: Localhost via UNIX socket