Postgres数据库和服务器的版本冲突

Mad*_*ddy 8 database postgresql database-connection postgresql-9.1

我在Mac OS X 10.6.x上安装了postgres。当我运行postgres数据库版本时:

psql --versionpsql (PostgreSQL) 9.1.1
contains support for command-line editing
Run Code Online (Sandbox Code Playgroud)

当我检查服务器的版本时:

psql -c "select version();"                                                                     version                                                                      
--------------------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.0.5 on x86_64-apple-darwin10.8.0, compiled by GCC i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3), 64-bit
(1 row)
Run Code Online (Sandbox Code Playgroud)

所以当我跑步

bash-3.2$ psql
psql (9.1.1, server 9.0.5)
WARNING: psql version 9.1, server version 9.0.
         Some psql features might not work.
Run Code Online (Sandbox Code Playgroud)

我不确定这些功能是什么。这些版本存在冲突。我是使用postgres的新手,所以我不知道如何仅升级postgres服务器。我试图在网上搜索某些内容,但没有太大帮助。我不想卸载并重新安装postgres。无论如何,我可以在没有冲突的情况下一起使用它们吗?还是只是将服务器升级到与数据库相同的版本?

编辑:

which psql
/opt/local/lib/postgresql91/bin//psql

which postgres
/opt/local/lib/postgresql91/bin//postgres

ps -eaf|grep postgres
    0    60     1   0   0:00.07 ??         0:00.09 /opt/local/bin/daemondo --label=postgresql90-server --start-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper restart ; --pid=none
  103  3971  3967   0   0:00.69 ??         0:01.17 postgres: writer process     
  103  3972  3967   0   0:00.67 ??         0:00.88 postgres: wal writer process     
  103  3973  3967   0   0:00.18 ??         0:00.23 postgres: autovacuum launcher process     
  103  3974  3967   0   0:00.19 ??         0:00.21 postgres: stats collector process     
    0  3616  2726   0   0:00.04 ttys000    0:00.06 su postgres
  103  3967  3619   0   0:00.23 ttys000    0:00.34 postgres -D /usr/local/pgsql/data
    0  4559  4055   0   0:00.03 ttys001    0:00.05 su postgres
  103  5922  4560   0   0:00.01 ttys001    0:00.01 grep postgres
Run Code Online (Sandbox Code Playgroud)

谢谢。

bou*_*uby 5

我的安装是自制软件,这就是我所做的(使我能够正常运行 psql,没有版本问题)——我正在尝试安装 KyngChaos 的 mac 版本的 postgresql

步骤0:

brew uninstall postgresql
Run Code Online (Sandbox Code Playgroud)

步骤1:

which psql
/path/to/psql  #in my case: /usr/bin/psql
sudo rm /path/to/psql
Run Code Online (Sandbox Code Playgroud)

第2步:

#inside ~/.bash_profile
export PATH=/usr/local/pgsql-9.3/bin:$PATH
Run Code Online (Sandbox Code Playgroud)

步骤3:

psql
#works
Run Code Online (Sandbox Code Playgroud)

  • 为什么要删除 psql 位置?(这是`/usr/bin/psql`) (3认同)

vye*_*rov 4

我想您之前已经安装了 PostgreSQL。请确认这一点,因为在这种情况下您将必须升级数据库。这是重要的一步,不可能仅仅升级软件。

请尝试停止当前正在运行的服务器。首先,检查当前运行的 PostgreSQL 的来源:

sudo launchctl list | grep -Ei "macports|postgres"
Run Code Online (Sandbox Code Playgroud)

然后执行:

sudo launchctl unload -w <OldPostgreSQL.plist>
Run Code Online (Sandbox Code Playgroud)

并像这样启动一个新服务器:

sudo launchctl load -w <NewPostgreSQL.plist>
Run Code Online (Sandbox Code Playgroud)

我希望新的 plist 是
/Library/LaunchDaemons/org.macports.postgresql91-server.plist.


如果您需要升级:

  1. 确保首先使用版本的pg_dump.
  2. 在新文件夹中执行版本的。initdbPGDATA
  3. 如上所述启动一个新服务器。
  4. 上传完整转储。

这是我在这个主题上遇到的一个小描述。这是有关主要版本之间升级的 PostgreSQL 官方文档