2017-01-25 23 views
3

我试图将9.5版本的postgres升级到9.6。 brew upgrade postgresql成功,但运行数据库用户“postgres”不是安装用户

pg_upgrade -b /usr/local/Cellar/postgresql/9.5.3/bin/ -B /usr/local/Cellar/postgresql/9.6.1/bin/ -d /usr/local/var/postgres -D /usr/local/var/postgres9.6 -U postgres 

,当我得到一个错误

Performing Consistency Checks 
----------------------------- 
Checking cluster versions         ok 
Checking database user is the install user 
database user "postgres" is not the install user 
Failure, exiting 

它变得更加古怪的末尾而不-U postgres当试图

Performing Consistency Checks 
----------------------------- 
Checking cluster versions         ok 
Checking database user is the install user     ok 
Checking database connection settings      ok 
Checking for prepared transactions       ok 
Checking for reg* system OID user data types    ok 
Checking for contrib/isn with bigint-passing mismatch  ok 
Checking for roles starting with 'pg_'      ok 
Creating dump of global objects        ok 
Creating dump of database schemas 
                  ok 
Checking for presence of required libraries     ok 
Checking database user is the install user 
database user "dimid" is not the install user 

那么如何来

Checking database user is the install user     ok 

回答

2

旧的PostgreSQL集群明显与

initdb -U dimid 

创建,但在新的群集用不同的超级用户istalled。

您必须创建与旧的超级用户名相同的新群集。

+0

谢谢,我怎么能找出哪个用户创建一个集群? – dimid

+1

你可以用'SELECT rolname FROM pg_roles WHERE oid = 10'来做到这一点,但这不是必须的。只需放下新簇,然后用'-U dimid'重新创建它。 –

+0

谢谢,这个伎俩。出于好奇,“10”是指什么? – dimid

2

专门为自制的PostgreSQL安装,用于初始化数据库,默认用户为$ USER - 所以,如果你只是按照说明开始和不喜欢的东西

​​

安装用户是你的Unix用户名。在我的情况下,它是'抢',所以只是添加'-U抢'的pg_upgrade工程以及:

pg_upgrade -b /usr/local/Cellar/postgresql/9.5.4_1/bin -B /usr/local/Cellar/postgresql/9.6.2/bin -d /usr/local/var/postgres95 -D /usr/local/var/postgres -U rob 
+0

许多其他用户可能会postgres所以只是使用它,而不是这个错误消息与你的名字不是安装用户 – engineerDave

+0

是的,'postgres'是首选的安装用户,因为这是默认的,因此是什么用户(像我)会先尝试。如本答案中所述,使用$ USER作为初始initdb特定于OSX/MacOS上PostgreSQL的自制安装。 – robm

相关问题