简体   繁体   中英

sudo -u postgres not working in mac os x

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.

sudo -u postgres -h localhost createdb template_postgis

This gives me no error but shows the usage of 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.

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:

   -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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM