Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

windows - 为Postgres工具设置Windows PATH(Setting Windows PATH for Postgres tools)

I cannot access PostgreSQL through the command line in Windows. (我无法通过Windows中的命令行访问PostgreSQL。) 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. (尽管我能够创建和更新数据库,可以通过PGAdminIII访问它们并推送到Heroku,但是我无法使用psql命令通过命令行直接访问它们。)

When I try to create a database by using the command (当我尝试使用命令创建数据库时)

$ createdb mydb

as explained in the PG documentation , I get the message (如PG文档中所述,我收到消息)

createdb: command not found

The documentation suggests that in this case, "PostgreSQL was not installed properly. Try calling the command with an absolute path instead." (文档建议在这种情况下,“未正确安装PostgreSQL。请尝试使用绝对路径调用该命令。”) Sure enough, I am able to create a database by entering the direct path to the file: (当然,我可以通过输入文件的直接路径来创建数据库:)

$ c:/postgreSQL/9.1/bin/createdb mydb

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. (我目前在系统路径和用户(:Umezo)路径中都添加了/ bin和/ lib路径,但是仍然无法从命令行进行访问。)

User variables for umezo
variable name: Path
variable value: C:PostgreSQL9.1in; C:PostgreSQL9.1lib

System variables
variable name: Path
variable value: C:PostgreSQL9.1in; C:PostgreSQL9.1lib

Any information or feedback regarding how I can fix my installment would be appreciated. (关于如何修理我的分期付款的任何信息或反馈,将不胜感激。)

My info is as below: (我的信息如下:)

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. (我安装了9.1的32位版本,因为某些资料显示64位存在问题。)

PG download version: Installer Version 9.1 Win x86-32
Operating System: Windows 7 (64 bit)

pg_hba.conf (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 (postgresql.conf)

# - Connection Settings -
listen_addresses = '*'
port = 5432
max_connections = 100

pg_ident.conf (pg_ident.conf)

# *Everything is commented out*

Login Role Umezo #from properties window in PGAdminIII (PGAdminIII中“属性”窗口中的 登录角色Umezo )

Properties/Role name: Umezo
Properties/Can login: "check"
Role privileges: all categories "check"
  ask by umezo translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

configuring postreSQL PATH variable on Windows 7 (在Windows 7上配置postreSQL PATH变量)

I encountered this issue too. (我也遇到了这个问题。) I'm using Git Bash , hence the Unix-style $ prompt on Windows. (我正在使用Git Bash ,因此在Windows上使用Unix风格的$提示符。)

$ rails db
Couldn't find database client: psql, psql.exe.  Check your $PATH and try again.

Here's what I did: (这是我所做的:)

In Windows 7, navigate to: (在Windows 7中,导航至:)

Control Panel
  All Control Panel Items
    System
      Advanced System Settings
        Environment Variables
          from the System Variables box select "PATH"
              Edit...

Then append this string to the existing PATH Variable Value: (然后将此字符串附加到现有的PATH变量值:)

;C:\Program Files\PostgreSQL\9.2\bin

and click "OK" three times to exit the menus. (然后单击“确定”三下退出菜单。)

Now, close the console and restart it. (现在,关闭控制台并重新启动它。)

Navigate back to the directory of your Rails app. (导航回到Rails应用程序的目录。) In my case, this is accomplished with: (就我而言,这是通过以下方式完成的:)

$ cd rails_projects/sample_app

Then, try again: (然后,再试一次:)

$ rails db

sources: (资料来源:)

How do I put PostgreSQL /bin directory on my path in Windows? (如何在Windows的路径上放置PostgreSQL / bin目录?)

http://railscasts.com/episodes/342-migrating-to-postgresql?view=asciicast (http://railscasts.com/episodes/342-migrating-to-postgresql?view=asciicast)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...