为Postgres工具设置Windows PATH [英] Setting Windows PATH for Postgres tools
问题描述
我无法通过Windows中的命令行访问PostgreSQL.尽管我能够创建和更新数据库,通过PGAdminIII访问它们并推送到Heroku,但我无法直接通过它们访问它们我的命令行使用psql命令.
I cannot access PostgreSQL through the command line in Windows. Although I am able to create and update the databases, access them through PGAdminIII, and push to Heroku, I am unable to access them directly through my command line using the psql command.
当我尝试使用命令创建数据库时
When I try to create a database by using the command
$ createdb mydb
如 PG文档所述,我得到了消息
createdb: command not found
文档建议在这种情况下,未正确安装PostgreSQL.请尝试使用绝对路径调用该命令."果然,我可以通过输入文件的直接路径来创建数据库:
The documentation suggests that in this case, "PostgreSQL was not installed properly. Try calling the command with an absolute path instead." Sure enough, I am able to create a database by entering the direct path to the file:
$ c:/postgreSQL/9.1/bin/createdb mydb
这是否意味着可以重新配置路径以正确连接?还是我需要重新安装?我已经重新安装了几次,但无法设置正确的路径.我目前已经将/bin和/lib路径都添加到了系统路径和user(:Umezo)路径中,但是仍然无法从命令行进行访问.
Does this mean that the path can be reconfigured to connect correctly? Or do I need to reinstall? I've reinstalled several times, and have not been able to set the correct path. I currently have both the /bin and /lib paths addedto my system and user(:Umezo) paths, but still no access from the command line.
User variables for umezo
variable name: Path
variable value: C:\PostgreSQL\9.1\bin; C:\PostgreSQL\9.1\lib
System variables
variable name: Path
variable value: C:\PostgreSQL\9.1\bin; C:\PostgreSQL\9.1\lib
任何有关如何修复我的分期付款的信息或反馈将不胜感激.
Any information or feedback regarding how I can fix my installment would be appreciated.
我的信息如下:
我主要关注这些资源此处和此处.我安装了9.1的32位版本,因为一些消息源建议使用64位.
I mostly followed these sources here and here. I installed a 32 bit version of 9.1 because some sources suggested issues with 64 bit.
PG download version: Installer Version 9.1 Win x86-32
Operating System: Windows 7 (64 bit)
pg_hba.conf
#TYPE DATABASE USER CIER-ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
postgresql.conf
# - Connection Settings -
listen_addresses = '*'
port = 5432
max_connections = 100
pg_ident.conf
# *Everything is commented out*
登录角色Umezo #从PGAdminIII的属性窗口中
Properties/Role name: Umezo
Properties/Can login: "check"
Role privileges: all categories "check"
推荐答案
在Windows 7上配置postreSQL PATH变量
我也遇到了这个问题.我使用的是 Git Bash ,因此使用Unix风格的$提示符Windows.
configuring postreSQL PATH variable on Windows 7
I encountered this issue too. I'm using Git Bash, hence the Unix-style $ prompt on Windows.
$ rails db
Couldn't find database client: psql, psql.exe. Check your $PATH and try again.
这就是我所做的:
在Windows 7中,导航至:
In Windows 7, navigate to:
Control Panel
All Control Panel Items
System
Advanced System Settings
Environment Variables
from the System Variables box select "PATH"
Edit...
然后将此字符串附加到现有的PATH变量值:
Then append this string to the existing PATH Variable Value:
;C:\Program Files\PostgreSQL\9.2\bin
然后单击确定"三次,退出菜单.
and click "OK" three times to exit the menus.
现在,关闭控制台并重新启动它.
Now, close the console and restart it.
导航回到Rails应用程序的目录.就我而言,这是通过以下方式完成的:
Navigate back to the directory of your Rails app. In my case, this is accomplished with:
$ cd rails_projects/sample_app
然后,再试一次:
$ rails db
来源:
如何放置PostgreSQL /bin目录在Windows中的路径上?
http://railscasts.com/episodes/342-migrating- to-postgresql?view = asciicast
这篇关于为Postgres工具设置Windows PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!