在 MacO 上安装 Postgresql Yosemite
Install Postgresql on a MacOs Yosemite
我正在尝试在基于 Yosemite 的 osX 上安装 postgresql 以使用 Rails。
我徒劳地尝试了不同的事情:
- 酿造。
- postgre.app
- 直接从 postgresql 站点下载的 dmg。
当我在 cli 中输入 which psql 时,我得到了这个:
psql is /usr/local/bin/psql
psql is /usr/local/bin/psql
psql is /usr/local/Cellar/postgresql/9.5.0/bin/psql
psql is /usr/local/bin/psql
如果我启动 foreman start 我有这个错误:
10:54:47 worker.1 | Is the server running locally and accepting
10:54:47 worker.1 | connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
如果我输入 psql,我也会遇到这个错误:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
使用 macports 安装 postgresql 对我有用。您可以下载安装程序并打开终端-window。编辑你的 .bashrc 如果你使用 bash,我使用 zsh 所以我编辑了 .zshrc 但行是相同的:
export PATH=/usr/local/bin:/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql94/bin:$PATH
关闭并打开一个新的终端-window并输入
sudo port selfupdate
它会下载所有可用的 macports 包。完成后,您可以使用
安装 postgresql
sudo port install postgresql94-server
更改您的路径以匹配您正在使用的 postgresql 版本,我的是版本。 9.4.版本。 9.5 也可用。
通过读取 this 线程使 postgreql 在您的机器启动时启动。这也说明了如何初始化数据库。
您可以将您的用户名添加到 postgresql 以便它可以创建数据库。这样可以方便开发时测试等。
PGUSER=postgres createuser your-username
Macport 将其安装的所有内容放在 /opt 中,数据库和配置文件放在 /opt/local/var/db/postgresql94 中。其他配置文件通常进入 /opt/local/etc.
我尝试通过 Mac 端口安装 postgresql 没有成功。
我清理了所有 postgresql 安装,然后再次尝试通过 brew 安装,但 运行 foreman start 时我仍然遇到错误。
我有两个错误,我的配置需要 postgresql 9.4,而我安装的是 9.5 版。
另一个错误发生了,我不得不在 database.yml 的开发配置中添加以下行。我认为这是主要问题。
host: localhost
我正在尝试在基于 Yosemite 的 osX 上安装 postgresql 以使用 Rails。 我徒劳地尝试了不同的事情: - 酿造。 - postgre.app - 直接从 postgresql 站点下载的 dmg。
当我在 cli 中输入 which psql 时,我得到了这个:
psql is /usr/local/bin/psql
psql is /usr/local/bin/psql
psql is /usr/local/Cellar/postgresql/9.5.0/bin/psql
psql is /usr/local/bin/psql
如果我启动 foreman start 我有这个错误:
10:54:47 worker.1 | Is the server running locally and accepting
10:54:47 worker.1 | connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
如果我输入 psql,我也会遇到这个错误:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
使用 macports 安装 postgresql 对我有用。您可以下载安装程序并打开终端-window。编辑你的 .bashrc 如果你使用 bash,我使用 zsh 所以我编辑了 .zshrc 但行是相同的:
export PATH=/usr/local/bin:/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql94/bin:$PATH
关闭并打开一个新的终端-window并输入
sudo port selfupdate
它会下载所有可用的 macports 包。完成后,您可以使用
安装 postgresqlsudo port install postgresql94-server
更改您的路径以匹配您正在使用的 postgresql 版本,我的是版本。 9.4.版本。 9.5 也可用。
通过读取 this 线程使 postgreql 在您的机器启动时启动。这也说明了如何初始化数据库。
您可以将您的用户名添加到 postgresql 以便它可以创建数据库。这样可以方便开发时测试等。
PGUSER=postgres createuser your-username
Macport 将其安装的所有内容放在 /opt 中,数据库和配置文件放在 /opt/local/var/db/postgresql94 中。其他配置文件通常进入 /opt/local/etc.
我尝试通过 Mac 端口安装 postgresql 没有成功。 我清理了所有 postgresql 安装,然后再次尝试通过 brew 安装,但 运行 foreman start 时我仍然遇到错误。
我有两个错误,我的配置需要 postgresql 9.4,而我安装的是 9.5 版。 另一个错误发生了,我不得不在 database.yml 的开发配置中添加以下行。我认为这是主要问题。
host: localhost