在mac os x上不工作的sudo -u postgres。

时间:2021-07-31 00:14:36

I have recently installed postgresql 9.1 after uninstalling postgres 9.3 as per the requirement of my project but I am not able to run basic sudo command with postgres user.

我最近安装了postgresql 9.1,根据我的项目的要求卸载了postgres 9.3,但是我不能使用postgres用户运行basic sudo命令。

sudo -u postgres -h localhost createdb template_postgis

This gives me no error but shows the usage of sudo:

这没有给我错误,但是显示了sudo的用法:

usage: sudo -h | -K | -k | -L | -V
usage: sudo -v [-AknS] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U user name] [-u
        user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user
        name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user
        name|#uid] file ...

Though sudo works for other projects and commands but not in this. It was working earlier perfectly. I will be really thankful if someone helps.

虽然sudo在其他项目和命令中工作,但不是在这方面。它工作得更早了。如果有人帮忙,我会非常感激的。

1 个解决方案

#1


2  

In the manual page for sudo (which you can view by running man sudo in the terminal), you can see that this is exactly what the -h option does:

在sudo的手册页面中(您可以通过在终端运行man sudo查看),您可以看到这正是-h选项所做的:

   -h          The -h (help) option causes sudo to print a usage message and exit.

You should be able to run the command without that option:

您应该能够在没有该选项的情况下运行该命令:

sudo -u postgres createdb template_postgis

#1


2  

In the manual page for sudo (which you can view by running man sudo in the terminal), you can see that this is exactly what the -h option does:

在sudo的手册页面中(您可以通过在终端运行man sudo查看),您可以看到这正是-h选项所做的:

   -h          The -h (help) option causes sudo to print a usage message and exit.

You should be able to run the command without that option:

您应该能够在没有该选项的情况下运行该命令:

sudo -u postgres createdb template_postgis