Mig*_*cia 6 postgresql macports osx-yosemite
我想安装PostgreSQL我正在开发的节点项目OSX Yosemite.我使用MacPorts,所以尝试了这里描述的方法:https://github.com/codeforamerica/ohana-api/wiki/Installing-PostgreSQL-with-MacPorts-on-OS-X
...但我在第2步中遇到错误:
$ sudo gem install pg -- --with-pg-config=/opt/local/lib/postgresql93/bin/pg_config > ruby_error
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/opt/local/lib/postgresql93/bin/pg_config
Using config values from /opt/local/lib/postgresql93/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Run Code Online (Sandbox Code Playgroud)
...认为我可能不需要安装pg gem,因为我想使用Node而不是Ruby,我接下来的步骤.但是在第3.3步中我遇到了一个错误:
$ sudo su postgres -c '/opt/local/lib/postgresql93/bin/initdb -D /opt/local/var/db/postgresql93/defaultdb'
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "postgres" is needed by initdb but was not found in the
same directory as "initdb".
Check your installation.
Run Code Online (Sandbox Code Playgroud)
...检查我的/ opt/local/lib/postgresql93/bin /目录,我看到了两个initdb和postgres.我看到那些说法Permission denied,我想知道那是什么.
不知道如何进步.考虑使用Postgres.app,如果真的更容易,但不确定使用MacPorts安装是否会更好,因为我使用MacPorts安装了大多数其他东西.关于我的任何问题的提示表示赞赏!
Ian*_*Gow 14
在权限上的目录/所有权/并defaultdb可能需要修正.我认为PostgreSQL可能对这些的所有权很敏感,虽然看起来在你的情况下PostgreSQL根本无法访问这些.这就是我对每个目录的拥有.
$ ls -hlt /opt/local/var/db/
total 0
drwxr-xr-x 7 root admin 238B Jan 23 16:54 texmf
drwxr-xr-x 3 root admin 102B Dec 25 07:37 postgresql94
Run Code Online (Sandbox Code Playgroud)
您可以sudo chmod a+rx /opt/local/var/db/根据需要修复权限.
对于defaultdb目录本身,您应该按照链接的说明进行操作,这些说明似乎与我的相同:
sudo chown postgres:postgres /opt/local/var/db/postgresql93/defaultdb
Run Code Online (Sandbox Code Playgroud)
以下是从我的博客改编的说明(虽然我建议使用PostgreSQL 9.4,我现在这样做).我从9.1开始使用MacPorts运行PostgreSQL而没有出现重大问题.
当然,我假设你已经在你的系统上启动并运行了MacPorts.
sudo port install postgresql93 +perl +python27
sudo port install postgresql93-server
Run Code Online (Sandbox Code Playgroud)
我首先需要初始化数据库集群,然后让服务器运行.以下内容直接来自MacPorts端口随附的屏幕说明postgresql93-server.
sudo mkdir -p /opt/local/var/db/postgresql93/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql93/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql93/bin/initdb -D /opt/local/var/db/postgresql93/defaultdb'
Run Code Online (Sandbox Code Playgroud)
请注意,MacPorts会创建一个启动守护程序.要立即加载它并确保它在系统启动时启动,请执行以下操作:
sudo defaults write /Library/LaunchDaemons/org.macports.postgresql93-server.plist Disabled -bool false
sudo launchctl load /Library/LaunchDaemons/org.macports.postgresql93-server.plist
Run Code Online (Sandbox Code Playgroud)
然后我用它psql进行一些设置以使我的数据库运行.
sudo su - postgres
/opt/local/lib/postgresql93/bin/psql -U postgres -d template1
Run Code Online (Sandbox Code Playgroud)
如果你到这里,那么你的系统上运行PostgreSQL.
尝试运行时我遇到了同样的问题initdb,即使遵循Ian Gow的描述:
$ sudo su postgres -c '/opt/local/lib/postgresql94/bin/initdb -D /opt/local/var/db/postgresql94/defaultdb'
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "postgres" is needed by initdb but was not found in the
same directory as "initdb".
Check your installation.
Run Code Online (Sandbox Code Playgroud)
事实证明,postgres如果你试图让它从你自己的主目录中运行命令,用户就无法做任何事情,因为在那里postgres不允许读取它自己的位置,因此也无法找出任何其他路径.所以简单的解决方案是运行cd /必须运行的任何命令之前postgres(initdb,pg_ctl,等等).之后,您可以使用快速跳回到以前的工作目录cd -.
| 归档时间: |
|
| 查看次数: |
4624 次 |
| 最近记录: |