【问题标题】:Mismatching pg_dump on MacOS XMacOS X 上的 pg_dump 不匹配
【发布时间】:2014-01-12 19:38:09
【问题描述】:

在本地,我似乎安装了 Postgresql 9.2.4。我根据收到的最后一条错误消息猜测我没有最新版本:

pg_dump: server version: 9.3.1; pg_dump version: 9.2.4
pg_dump: aborting because of server version mismatch

在这里的其他帖子中,被告知要做的是在 .profile 之后添加以下内容,然后运行命令:

export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
. ~/.profile

这不起作用。

2 周前,我用简单的命令安装了 Postgresql:

brew install postgresql

这给了我目前拥有的版本。看来我当时没有最新版本。

我该如何 a) 升级到 9.3.1(这是服务器版本的样子)或 b) 执行这些修复之一,就像我在上面尝试的那样没有工作。

我是 Postgresql 的新手,所以一步一步对我很有帮助。

【问题讨论】:

    标签: macos postgresql


    【解决方案1】:

    通过在我的~/.bash_profile(或~/.zshrc for zsh)的末尾添加这个来解决

    export PG_DUMP="/Applications/Postgres.app/Contents/Versions/9.6/bin/"
    PATH=$PG_DUMP:$PATH
    

    别忘了运行(对于 bash shell)

    $ source ~/.bash_profile
    

    或(对于 zsh)

    $ source ~/.zshrc
    

    可以通过运行查看pg_dump的路径

    $ which pg_dump
     ==> /Applications/Postgres.app/Contents/Versions/9.6/bin//pg_dump
    
    • MacOS Mojave (10.14.2)
    • Postgres.app (2.1.5)
    • PostgreSQL 9.6

    【讨论】:

    • source ~/.bash_profile 假设用户使用的是 bash shell 而不是 zsh
    【解决方案2】:
    酿造升级postgresql 酿造链接——覆盖postgresql

    【讨论】:

      【解决方案3】:

      在 Postgresql 9.2 和 9.3 之间您必须遵循升级说明...

      1. launchctl 卸载 ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
      2. mv /usr/local/var/postgres /usr/local/var/postgres92
      3. 酿造更新
      4. brew 升级 postgresql
      5. initdb /usr/local/var/postgres -E utf8
      6. pg_upgrade -b /usr/local/Cellar/postgresql/9.2.4/bin -B /usr/local/Cellar/postgresql/9.3.1/bin -d /usr/local/var/postgres92 -D /usr /local/var/postgres
      7. launchctl 加载 ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

      【讨论】:

      • 我没有你说的第一个文件。我在这个文件夹中的自制软件只有一个 redis 文件,当我简单地运行“brew upgrade postgresql”时,它说 postgresql-9.2.4 已经安装
      • 然后跳过该步骤并继续其他步骤。使用常识。主要思想是您必须在新旧数据库二进制文件之间运行pg_upgrade 步骤。
      • 你也必须升级自制软件,我会为此添加额外的步骤。
      • asker根据报错信息已经运行了9.3.1的服务器,所以这一切都没有意义。
      • 我现在已经下载了9.3.2,太好了!第 5 步给我一个错误,说目录存在。
      猜你喜欢
      • 2014-04-10
      • 1970-01-01
      • 2014-02-03
      • 2014-07-28
      • 2013-07-20
      • 2020-12-29
      • 2012-12-19
      • 2016-09-29
      • 1970-01-01
      相关资源
      最近更新 更多