如何将 PostgreSQL /bin 目录放在 Windows 中的路径上?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12279856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I put PostgreSQL /bin directory on my path in Windows?
提问by user1648507
I've got a fairly simple question I guess. I'm working on a Ruby on Rails app. I'm trying to switch to PostgreSQL thanks to Heroku.
我想我有一个相当简单的问题。我正在开发一个 Ruby on Rails 应用程序。感谢 Heroku,我正在尝试切换到 PostgreSQL。
In my database.yml file it states:
在我的 database.yml 文件中,它指出:
Install PostgreSQL and put its /bin directory on your path.
Install PostgreSQL and put its /bin directory on your path.
My question is how do I put PostgreSQL's /bin directory on my path? Exactly which file do I modify and how?
我的问题是如何将 PostgreSQL 的 /bin 目录放在我的路径上?我究竟要修改哪个文件以及如何修改?
I imagine this is my issue since when I run the "rails db" command i get:
我想这是我的问题,因为当我运行“rails db”命令时,我得到:
"Couldn't find database client: psql,psql.exe. Check your $PATH and try again."
“找不到数据库客户端:psql,psql.exe。请检查您的 $PATH 并重试。”
Thanks everyone! Robin.
感谢大家!罗宾。
回答by Hans Chen
Append the directory to system PATH
(not user PATH
) by Environment Variables, using a semicolon to separate it from the previous entry.
通过环境变量将目录附加到 system PATH
(而不是 user PATH
),使用分号将其与上一个条目分开。
You can find it from control pannel -> system -> Advanced -> Environment Variables
您可以从控制面板-> 系统-> 高级-> 环境变量中找到它
回答by Nawshine
Ran into the same issue and tried the solution mentioned here
遇到同样的问题并尝试了这里提到的解决方案
[user@host user]$
psql
bash: psql: command not found
[user@host user]$
echo $PATH
/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin
[user@host user]$
export PATH=$PATH:/usr/local/pgsql/bin
[user@host user]$
psql testdb
Should do the trick.
应该做的伎俩。
回答by Rubyman
You need to install Postgres first then add the path to system properties > environment variables > in system variables section you will see PATH variable
您需要先安装 Postgres,然后将路径添加到系统属性 > 环境变量 > 在系统变量部分,您将看到 PATH 变量
回答by Kevin
This is my preferred way of adding a new location to the PATH environment variable (on modern Red-Hat-based systems):
这是我向 PATH 环境变量添加新位置的首选方式(在基于 Red-Hat 的现代系统上):
echo 'export PATH="/usr/pgsql-9.3/bin:$PATH"' | sudo tee /etc/profile.d/pgsql.sh
- PATH is a colon
:
separated list of directories that are search, in order, for a called program. - Profile configurations under
/etc
are persistent for all users (but require the active shell tosource
them to take effect). - The version number is tacked on to the PostgreSQL directory when it is installed from their repository.
- PATH 是以冒号
:
分隔的目录列表,按顺序搜索被调用的程序。 - 下面的配置文件配置
/etc
对所有用户都是持久的(但需要source
他们的活动 shell 才能生效)。 - 当从它们的存储库安装时,版本号被附加到 PostgreSQL 目录中。