当前位置: 首页 >> 应用软件 >> 数据库 >> debian下的postgresql使用
 

debian下的postgresql使用

作者:      来源:cublog.cn/u/648/showart.php?id=90112     发表时间:2006-04-19     浏览次数:      字号:    

在debian下安装东西是很简单, apt-get install postgresql 就都搞定了。

安装完成后系统就启动了pg的服务,用netstat -ln 可以看到有5432端口等待连接,

#su - postgres   #转成postgres系统用户
$psql -d template1    #使用postgres用户进入数据库,连接template1数据库,这里不指定一个数据库的话,似乎不让进入数据库
template1=#create user ftp with password 'YOURPASSWORD';  #创建数据库用户ftp
template1=#create database ftp with owner = ftp ;   #创建数据库ftp,属主名也是ftp
template1=#\q
$exit
然后修改/etc/postgresql/pg_hba.conf文件,在下面这行
# All IPv4 connections from localhost
后门加入
host    ftp     ftp     127.0.0.1       255.255.255.255         md5
然后/etc/init.d/postgresql restart ;接着就可以使用
$psql -h localhost -U ftp -W ftp
来登录数据库了,象下面这样:

 psql -h localhost -U ftp -W ftp
Password:
Welcome to psql 7.4.7, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

ftp=>


自己记下,这个东西折腾了我不少时间,手册上单单看用户认证那一部分似乎讲得并不多。

tips:再记个东西,,手册上写的东西也不能完全相信:

GRANT SELECT ON user TO ftp;

我今天就是老是这个错误:ERROR: syntax error at or near "user" at character 24

最后发现:需要在user上加上双引号,即:

GRANT SELECT ON "user" TO ftp;

这样就成功的授权了。。。可怜折腾了我很久。

责任编辑 webmaster

 
 
 
 
 
评论更多>>
 
 
 
发表
 
姓名: QQ:
性别: MSN:
E-mail: 主页:
评分: 1 2 3 4 5
评论内容:
验证码:
  
  • 请遵守《互联网电子公告服务管理规定》及中华人民共和国其他各项有关法律法规。
  • 严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
  • 用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表网友个人观点,与本网站立场无关。
  •