我在Mac OS X 10.6.x上安装了postgres。当我运行 postgres 数据库版本时:
psql --versionpsql (PostgreSQL) 9.1.1
contains support for command-line editing
当我检查服务器版本时:
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)
所以当我跑步时
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.
我不确定这些功能是什么。这些版本是相互冲突的。我是使用 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
谢谢。
我的是一个自制安装,这就是我所做的(将我带到一个没有版本问题的正常运行的 psql)——我正在尝试安装 KyngChaos 的 mac 版本的 postgresql
步骤 0:
brew uninstall postgresql
第 1 步:
which psql
/path/to/psql #in my case: /usr/bin/psql
sudo rm /path/to/psql
第 2 步:
#inside ~/.bash_profile
export PATH=/usr/local/pgsql-9.3/bin:$PATH
第 3 步:
psql
#works
我想你之前已经安装了PostgreSQL。请确认这一点,因为在这种情况下,您必须升级数据库。这是重要的步骤,不可能只升级软件。
请尝试停止当前正在运行的服务器。首先,检查当前运行的 PostgreSQL 的源代码:
sudo launchctl list | grep -Ei "macports|postgres"
然后执行:
sudo launchctl unload -w <OldPostgreSQL.plist>
并像这样启动一个新服务器:
sudo launchctl load -w <NewPostgreSQL.plist>
我希望新的plist是
/Library/LaunchDaemons/org.macports.postgresql91-server.plist
.
如果您需要升级:
- 确保首先使用新版本的
pg_dump
对数据库进行完全转储。 - 在新的
PGDATA
文件夹中执行新版本的initdb
。 - 如上所述启动新服务器。
- 上传完整转储。
这是我在这个主题上遇到的一个小描述。这是关于在主要版本之间升级的官方PostgreSQL文档。
如果您在新安装之前已经拥有 PostgreSQL 版本,则可能会发生这种情况。
由于您有两个版本的 PostgreSQL,因此您需要两个版本的 psql。基本上,现在当您键入 psql 时,您的系统可能无法确定您尝试连接到哪个版本的数据库。
删除以前的版本。或者安装新的 psql 以及新版本的服务器。