【问题标题】:sudo -u postgres not working in mac os xsudo -u postgres 在 mac os x 中不起作用
【发布时间】:2014-12-19 13:03:04
【问题描述】:

我最近根据我的项目要求在卸载 postgres 9.3 后安装了 postgresql 9.1,但我无法使用 postgres 用户运行基本的 sudo 命令。

sudo -u postgres -h localhost createdb template_postgis

这没有给我任何错误,但显示了 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 ...

虽然 sudo 适用于其他项目和命令,但不适用于此。它早些时候工作得很好。如果有人提供帮助,我将非常感激。

【问题讨论】:

    标签: macos postgresql shell command-line sudo


    【解决方案1】:

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

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

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

    sudo -u postgres createdb template_postgis
    

    【讨论】:

    • -h &lt;hostname&gt; 参数应该在命令的 createdb 部分之后给出,因为它应该是 createdb 的参数,而不是 sudo 的参数。
    • 你们知道为什么在正常工作后我仍然收到此错误。 stackoverflow.com/questions/27560707/…
    猜你喜欢
    • 2013-01-05
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多