使用sudo启动Postgresql时出现问题

使用sudo启动Postgresql时出现问题,postgresql,ubuntu-17.10,Postgresql,Ubuntu 17.10,运行Ubuntu 17.10,我在运行Postgres时遇到了一个问题。几周前它还在工作,但现在我有这个问题 sudo su postgres psql /usr/bin/psql: line 19: use: command not found /usr/bin/psql: line 20: use: command not found /usr/bin/psql: line 21: use: command not found /usr/bin/psql: line 22: use: co

运行Ubuntu 17.10,我在运行Postgres时遇到了一个问题。几周前它还在工作,但现在我有这个问题

sudo su postgres psql

/usr/bin/psql: line 19: use: command not found
/usr/bin/psql: line 20: use: command not found
/usr/bin/psql: line 21: use: command not found
/usr/bin/psql: line 22: use: command not found
/usr/bin/psql: psql: line 24: syntax error near unexpected token `$version,'
/usr/bin/psql: psql: line 24: `my ($version, $cluster);'
我不知道该怎么办,语法看起来很正常。

试试看

sudo -u postgres psql
相反


我其实不知道你的命令是干什么的。快速查看
mansu
并不能真正阐明
su
对额外参数的作用,但显然它不是启动
psql
,它可能是将文件内容输入shell。

/usr/bin/psql
一个以
开头的Perl脚本/bin/sh
或类似产品?第24行表示它是Perl,第19行表示它是Perl被馈送到shell。感谢您的帮助,这是正确的。我用的是另一种方式,因为我看到其他人用它来启动postgres,我认为这是正确的方式。(错误的假设)不带“-u”或普通“-”的sudo将继承您当前的环境。使用“-”可以设置一个新的环境,就像您作为其他用户登录一样。