postgresql密码文件.pgpass
来源:互联网 发布:lcd1602液晶显示数组 编辑:程序博客网 时间:2024/05/09 20:13
也许你不像每次在登录的时候都用过psql的-W选项为某个用户输入密码,并且你不想把此用户在pg_hba.conf文件里设置为trust信任模式。那么可以尝试下使用POSTGRESQL的.pgpass文件。
首先,创建一个用户test
create user test;
并且使用alter user test password 'yourpassword'命令为该用户添加密码
再在pg_hba.conf文件里添加如下内容
host mysql test xx.xx.xxx.x/0 password
(xx处为你主机的完整IP地址)
登陆一把试试
[mysql@pttest4 ~]$ psql -h pttest4 -d mysql -U test -W
Password for user test:
Welcome to psql 8.2.16, 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
mysql=> /q
此时使用了-W选项,系统会提示你输入密码。下面我们添加~/.pgpass试试,内容为
pttest4:5432:mysql:test:test
保存以后,登录一把试试
[mysql@pttest4 ~]$ psql -h pttest4 -d mysql -U test
WARNING: password file "/home/mysql/.pgpass" has world or group read access; permission should be u=rw (0600)
Password for user test:
Welcome to psql 8.2.16, 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
mysql=> /q
这时我们可以看到,仍然会提示我们输入密码才能登录。仔细看一下WARNING,因为~/.pgpass文件的权限不正确,更改一下
[mysql@pttest4 ~]$ chmod 0600 .pgpass
[mysql@pttest4 ~]$ ls -al |grep .pgpass
-rw------- 1 mysql mysql 29 May 15 16:13 .pgpass
再次登录
[mysql@pttest4 ~]$ psql -h pttest4 -d mysql -U test
Welcome to psql 8.2.16, 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
mysql=>
OK,顺利登录
官方文档链接如下
http://www.postgresql.org/docs/current/static/libpq-pgpass.html
- postgresql密码文件.pgpass
- 使用.pgpass密码文件,通过psql登录greenplum
- linux下postgresql设置.pgpass无效
- PostgreSQL密码文件的设置
- postgreSQL 重新安装密码错误
- PostgreSQL pg_hba.conf 文件解析以及忘记密码的处理方法
- PostgreSQL数据库忘记密码解决方案
- PostgreSQL数据库的密码丢失
- [postgresql]安装时忘记密码
- postgresql数据库密码忘记解决办法
- Postgresql默认用户名与密码
- PostgreSQL忘记密码的解决办法
- postgresql修改账户postgres密码
- Postgresql默认用户名与密码
- postgresql无密码连接数据库
- PostgreSQL默认用户名与密码
- postgreSQL 去掉设置密码提示
- postgresql 导入sql文件
- 西乡大运会群文档
- 八个步骤开发完整的J2EE解决方案
- 解决 ORA-39095 ORA-3909 EXPDP 错误
- Flex高级动画教程中所讲的寻找行为
- CString 操作指南
- postgresql密码文件.pgpass
- 使用CSerialPort类编写串口通信程序的问题
- Struts,spring工作机制(总结)
- Struts,spring工作机制(总结)
- 计算机工程专业,如何找paper?
- 判断email格式正确与否
- 图形用户界面测试
- 八尾猫的故事
- .NET 如何生成DLL文件,并且调用