pg_dump version mismatch in Rails

时光怂恿深爱的人放手 提交于 2019-12-10 14:53:43

问题


When running the rake db:structure:dump command, I encountered the following error:

Larson-2:app larson$ rake db:structure:dump
pg_dump: server version: 9.1.3; pg_dump version: 9.0.4
pg_dump: aborting because of server version mismatch
rake aborted!
Error dumping database

How can I go about updating pg_dump? I have pg 9.1.3 installed, is there a way to update the references inside of Rails to the new version?

When I try to update postgres via homebrew, I get the following output:

Larson-2:app larson$ sudo brew upgrade postgresql
Password:
Error: postgresql already upgraded

回答1:


Here's how I resolved the issue, first update homebrew:

brew update
if you get this error: error: Your local changes to the following files would be overwritten by merge:

then:

cd /usr/local/cellar
git reset --hard FETCH_HEAD

After you finish updating homebrew:
sudo brew install postgresql
Which will install 9.1.3 (or the most current version of pg) and any dependencies.




回答2:


on my machine, the problem was with the PATH. there was a pg_dump v. 9.0.10 on /usr/bin and my server was 9.1.something.

Changing the path to make /usr/local/Cellar/postgres/9..../bin (or whatever is the path to the actual postgres installation you use) come before anything else worked like a breeze. I only had to re-open any open terminal window.




回答3:


I had the same issue. Followed the postgres command-line Tools documentation, then had to run rake db:reset then rake db:test:prepare to copy my test database over. After I did those things, it worked.



来源:https://stackoverflow.com/questions/9799690/pg-dump-version-mismatch-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!