免费注册 查看新帖 |

Chinaunix

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

psql的密码选项 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-09-05 16:06 |只看该作者 |倒序浏览
使用脚本创建数据库,为避免重复输入密码,需要把密码预置密码在脚本里,却发现找不到psql的密码选项.
是根本没有,还是....

请大家指教!

论坛徽章:
0
2 [报告]
发表于 2006-09-06 08:51 |只看该作者
大家都没有需要这么做过,还是都比较藏珍啊
看来主要是这个版太冷清了

论坛徽章:
0
3 [报告]
发表于 2006-09-11 14:55 |只看该作者
这个问题终于解决了,和大家分享一下,方法是在使用psql之前,给两个环境变量赋值。
set PGUSER=
set PGPASSWORD=
psql .....

希望大家不要笑话

[ 本帖最后由 shaver 于 2006-9-11 14:59 编辑 ]

论坛徽章:
0
4 [报告]
发表于 2008-02-02 18:00 |只看该作者
感谢lz分享,这库估计用的太少了,找这密码选项找好几天,先谢过了,回去试试

论坛徽章:
0
5 [报告]
发表于 2008-02-02 18:26 |只看该作者
晕,貌似不会用啊,有能人指教下吗,怎么使用,自动密码查询数据库表啊

论坛徽章:
0
6 [报告]
发表于 2008-02-03 18:07 |只看该作者
原帖由 shaver 于 2006-9-11 14:55 发表
这个问题终于解决了,和大家分享一下,方法是在使用psql之前,给两个环境变量赋值。
set PGUSER=
set PGPASSWORD=
psql .....

希望大家不要笑话



那你是你没有看帮助

Connection options:
  -h HOSTNAME     database server host or socket directory (default: "local socket")
  -p PORT         database server port (default: "5432")
  -U NAME         database user name (default: "postgres")
  -W              prompt for password (should happen automatically)


测试:

[postgres@localhost ~]$ /usr/local/pgsql/bin/psql
psql: FATAL:  no pg_hba.conf entry for host "[local]", user "postgres", database "postgres"

[postgres@localhost ~]$ /usr/local/pgsql/bin/psql -hlocalhost -U postgres
Welcome to psql 8.2.6, the PostgreSQL interactive terminal.

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

postgres=#
postgres=# \l
        List of databases
   Name    |  Owner   | Encoding
-----------+----------+----------
postgres  | postgres | UTF8
t_girl    | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
(4 rows)

postgres=#

论坛徽章:
0
7 [报告]
发表于 2008-02-03 18:08 |只看该作者
原帖由 shaver 于 2006-9-11 14:55 发表
这个问题终于解决了,和大家分享一下,方法是在使用psql之前,给两个环境变量赋值。
set PGUSER=
set PGPASSWORD=
psql .....

希望大家不要笑话



那你是你没有看帮助

Connection options:
  -h HOSTNAME     database server host or socket directory (default: "local socket")
  -p PORT         database server port (default: "5432")
  -U NAME         database user name (default: "postgres")
  -W              prompt for password (should happen automatically)


测试:

[postgres@localhost ~]$ /usr/local/pgsql/bin/psql
psql: FATAL:  no pg_hba.conf entry for host "[local]", user "postgres", database "postgres"

[postgres@localhost ~]$ /usr/local/pgsql/bin/psql -hlocalhost -U postgres
Welcome to psql 8.2.6, the PostgreSQL interactive terminal.

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

postgres=#

postgres=# \l

        List of databases
   Name    |  Owner   | Encoding
-----------+----------+----------
 postgres  | postgres | UTF8
 t_girl    | postgres | UTF8
 template0 | postgres | UTF8
 template1 | postgres | UTF8
(4 rows)

postgres=#

论坛徽章:
0
8 [报告]
发表于 2008-02-04 10:20 |只看该作者
如果输入错误,他会自动提示的
[root@localhost ~]# psql -upostgres -hlocalhost
psql: Warning: The -u option is deprecated. Use -U.
User name: postgres
Password for user :
psql: could not connect to server: Connection refused
        Is the server running on host "localhost" and accepting
        TCP/IP connections on port ostgres?

论坛徽章:
0
9 [报告]
发表于 2008-02-21 09:32 |只看该作者
晕,谢谢楼上的操作图,还是没找到,那里有密码输入项,或者把密码记录在哪里。是打算用脚本查询数据库,自动密码,不知具体怎么处理密码问题:)

论坛徽章:
0
10 [报告]
发表于 2008-02-22 11:04 |只看该作者
libpq 的连接函数中可以内置。。。脚本我还不清楚。。我也是每次输入密码,,切换用户,,有点烦躁..
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP