Chinaunix首页 | 论坛 | 博客
  • 博客访问: 562418
  • 博文数量: 86
  • 博客积分: 2581
  • 博客等级: 少校
  • 技术积分: 793
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-05 20:09
文章分类

全部博文(86)

文章存档

2009年(86)

我的朋友

分类: Mysql/postgreSQL

2009-07-18 10:13:26

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"有特定含义:
—— MySQL手册 5.6.4 ..... A Host value may be a hostname or an IP number, or 'localhost' to indicate the local host.


注意:虽然两者连接方式有区别,但当localhost 为默认的127.0.0.1时,两种连接方式使用的权限记录都是以下的1.row的记录(因为记录在前,先被匹配)

*************************** 1. row ***************************
                 Host: localhost
                 User: root
......

*************************** 2. row ***************************
                 Host: 127.0.0.1
                 User: root

证明:


shell> 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


shell> 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





阅读(5694) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-07-05 17:02:10

解释的挺详细的。:)