免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6834 | 回复: 6
打印 上一主题 下一主题

postgresql 8.3.1 普通用户看不到其他用户建立的数据库,模式(public),表 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-05-18 03:41 |只看该作者 |倒序浏览
如题:

小弟是新手,还请各位高手指教:)
小弟用的是postgresql 8.3.1,phppgadmin,
在phppgadmin 里建立了
user:  fox
用 fox 建立了数据库: itas,模式:public, 表: summary
又建立了用户: test
用命令赋予了权限: GRANT SELECT,INSERT ON summary TO test
但是当用 test 登录后,看不到 itas 数据库,用 SELECT * FROM summary 命令总是显示:
“关系summary不存在“

不知是权限的问题,还是搜索路径的问题呢?
还望高手赐教!

谢谢!

论坛徽章:
0
2 [报告]
发表于 2008-05-18 09:54 |只看该作者
看看你的pg_hda.conf文件,里面有没有给用户test访问数据库itas的权限

论坛徽章:
0
3 [报告]
发表于 2008-05-18 17:01 |只看该作者
谢谢您的回答!
主要是 test 用户不是我的操作系统用户,而只是 postgresql 的用户,我不知道该怎么认证。
下面是我的pg_hba.conf,请帮忙看一下,有没有什么问题,需要怎么设置?
谢谢!

# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident sameuser
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

论坛徽章:
0
4 [报告]
发表于 2008-05-18 22:40 |只看该作者
# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the
# PostgreSQL documentation for a complete description
# of this file.  A short synopsis follows.
#
# This file controls: which hosts are allowed to connect, how clients
# are authenticated, which PostgreSQL user names they can use, which
# databases they can access.  Records take one of these forms:
#
# local      DATABASE  USER  METHOD  [OPTION]
# host       DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
# hostssl    DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
# hostnossl  DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
#
# (The uppercase items must be replaced by actual values.)
#
# The first field is the connection type: "local" is a Unix-domain socket,
# "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an
# SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket.
#
# DATABASE can be "all", "sameuser", "samerole", a database name, or
# a comma-separated list thereof.
#
# USER can be "all", a user name, a group name prefixed with "+", or
# a comma-separated list thereof.  In both the DATABASE and USER fields
# you can also write a file name prefixed with "@" to include names from
# a separate file.
#
# CIDR-ADDRESS specifies the set of hosts the record matches.
# It is made up of an IP address and a CIDR mask that is an integer
# (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that specifies
# the number of significant bits in the mask.  Alternatively, you can write
# an IP address and netmask in separate columns to specify the set of hosts.
#
# METHOD can be "trust", "reject", "md5", "crypt", "password", "gss", "sspi",
# "krb5", "ident", "pam" or "ldap".  Note that "password" sends passwords
# in clear text; "md5" is preferred since it sends encrypted passwords.
#
# OPTION is the ident map or the name of the PAM service, depending on METHOD.
#
# Database and user names containing spaces, commas, quotes and other special
# characters must be quoted. Quoting one of the keywords "all", "sameuser" or
# "samerole" makes the name lose its special character, and just match a
# database or username with that name.
#
# This file is read on server startup and when the postmaster receives
# a SIGHUP signal.  If you edit the file on a running system, you have
# to SIGHUP the postmaster for the changes to take effect.  You can use
# "pg_ctl reload" to do that.

# Put your actual configuration here
# ----------------------------------
#
# If you want to allow non-local connections, you need to add more
# "host" records. In that case you will also need to make PostgreSQL listen
# on a non-local interface via the listen_addresses configuration parameter,
# or via the -i or -h command line switches.
#



# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# IPv4 local connections:
host    all         postgres     127.0.0.1/32               md5
host    all         postgres     192.168.40.220/32          md5
host    cx          cx           192.168.40.220/32          md5
# IPv6 local connections:
#host    all         all         ::1/128               md5



这是我的conf你看看

论坛徽章:
0
5 [报告]
发表于 2008-05-19 12:31 |只看该作者
你这个只是允许本地MD5访问吧。

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
tkdchen 该用户已被删除
6 [报告]
发表于 2008-05-19 14:58 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
7 [报告]
发表于 2008-05-19 23:35 |只看该作者
谢谢各位的热心!
我的情况是这样的:
由于条件限制(只有一台电脑),所以我装上postgresql 后,希望能在 本地 用普通的postgresql用户进行一些操作,例如 SELECT,INSERT 等等.

我的本地 ip: 192.168.1.6
postgresql superuser: fox
用 fox 建立了数据库: itas,模式:public, 表: summary
postgresql 普通用户: test
由 fox 用命令赋予了 test 权限: GRANT SELECT,INSERT ON summary TO test

现在的问题是:
在 phppgadmin 里,
当用 test 登录后,由于看不到 itas 数据库,所以用 SELECT * FROM summary 命令总是显示:
“关系summary不存在“

在SQL里面给表名加上public试试看。
select * from public.summary

这样也不行:(

我觉得也可能是 pg_hba.conf 的设置问题:
可是,我试验了一阵,结果如下:

A. pg_hba.conf 如下:

# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident sameuser
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

结果: fox 可以正常登录,test 可以正常登录但看不到数据库 itas.


B. pg_hba.conf 如下:

# Database administrative login by UNIX sockets
#local   all         postgres                          ident sameuser

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
#local   all         all                               ident sameuser
# IPv4 local connections:
host    all         fox         127.0.0.1/32          md5
host    all         fox         192.168.1.6/32          md5
host    itas        test        192.168.1.6/32          md5
# IPv6 local connections:
#host    all         all         ::1/128               md5

并且在 postgresql.conf 里设置: listen_addresses='*'

结果: fox,test 都不能正常登录.


C. pg_hba.conf 如下:

# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               md5

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
#host    all         all         ::1/128               md5

并且在 postgresql.conf 里设置: listen_addresses='localhost'


结果: fox,test 都不能正常登录.


小弟查过 manaul,结合上面的试验,想请教各位大哥:
1.如果在 postgresql.conf 里设置: listen_addresses='*',是不是所有的 ip 都有效,包括本机-192.168.1.6/127.0.0.1?
2.pg_hba.conf 里面的 METHOD 列:
   如果是 ident sameuser:  除了必须 password 正确,还必须有同名的操作系统用户。
   如果是 md5: 只要 password 正确就行.
   是不是这样呢?
   如果是这样,那麽下列设置为什么不能正常登录呢?
  local   all         all                               md5
3.下面两行设置是不是一样的效果呢?
   local   all         all                              md5
   host    all         all         127.0.0.1/32         md5

再次谢谢各位多多指教!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP