Hom*_*man 14 postgresql homebrew
我升级到了mavericks并且在安装/编译新宝石时遇到了一些麻烦,所以我重新安装了xcode并进行了brew更新和升级.宝石现在工作,甚至postgres继续工作一段时间,直到最近重新启动.现在postgres似乎有问题.
postgres:
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
brew info postgres:
postgresql: stable 9.3.2 (bottled)
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.2.4 (2842 files, 39M)
Built from source
/usr/local/Cellar/postgresql/9.3.2 (2924 files, 39M) *
Poured from bottle
postgres -D /usr/local/var/postgres:
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.3.2.
Run Code Online (Sandbox Code Playgroud)
我现在该怎么办才能让我的数据库再次运行?
sen*_*nel 26
$ brew tap homebrew/versions
$ brew install postgresql92
$ brew switch postgresql 9.2.8 # might need to check this one, could be newer by the time you read this
$ pg_dumpall > ninedottwo-dump
$ brew uninstall postgresql92
$ brew switch postgresql 9.3.4 # again, check version
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
$ createdb # i got an error about my database not existing, so i had to run this
$ psql < ninedottwo-dump
$ bundle exec rails s
Run Code Online (Sandbox Code Playgroud)
感谢Peter让我开始朝着正确的方向前进.
编辑:这将教我一次升级所有内容......
您需要以某种方式获得PostgreSQL 9.2的副本,以便能够访问现有的数据目录.
通过Homebrew安装9.2的选项包括:
postgresql公式升级到9.3 之前,先查看Homebrew .postgresql92从homebrew/versions水龙头安装.postgresql-9.2从petere/postgresql点击安装(披露:这是我的项目).那么你应该使用要么是升级到9.3 pg_dump或pg_upgrade.
pg_upgrade为此目的而来,使用它很简单.只需确保为旧数据和二进制文件指定正确的路径(-d和-b)以及指向新数据和二进制文件(-D和-B)的正确路径:
pg_upgrade \
-d /usr/local/var/postgres/9.2/ -D /usr/local/var/postgres/9.3/ \
-b /usr/local/Cellar/postgresql/9.2.4/bin/ -B /usr/local/Cellar/postgresql/9.3.2/bin/
Run Code Online (Sandbox Code Playgroud)
如果一切顺利,你可以用旧版本清理brew cleanup postgresql,因为新版本的PostgreSQL意味着Ruby pg gem使用的本机库的新版本,你可能想要重新编译它:
gem uninstall pg
ARCHFLAGS="-arch x86_64" gem install pg
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12833 次 |
| 最近记录: |