Linux command
createuser 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Create a user interactively
createuser [username]
Create superuser
createuser -s [username]
Create user with password prompt
createuser -P [username]
Create user that can create databases
createuser -d [username]
Create user with connection options
createuser -h [localhost] -p [5432] -U [admin] [username]
Create user that can create roles
createuser -r [username]
Create user with no login privilege (role only)
createuser --no-login [rolename]
说明
createuser is a PostgreSQL utility that creates new database users (roles). It's a wrapper around the SQL CREATE ROLE command, providing a convenient command-line interface. The tool can create users with various privileges including superuser status, database creation rights, and role creation abilities. It connects to the database server and executes the appropriate SQL.
参数
- -s, --superuser
- Create superuser.
- -d, --createdb
- Allow creating databases.
- -r, --createrole
- Allow creating roles.
- -l, --login
- Allow login (default).
- -P, --pwprompt
- Prompt for password.
- -e, --echo
- Show generated SQL.
- -h _host_
- Database server host.
- -p _port_
- Database server port.
- -U _user_
- Connect as user.
- -W
- Force password prompt.
- -i, --inherit
- Role inherits privileges (default).
- --no-inherit
- Role does not inherit privileges of roles it is a member of.
- --interactive
- Prompt for missing role attributes interactively.
- --no-login
- Role cannot log in (useful for group roles).
- --replication
- Allow replication connections.
- --no-replication
- Role cannot initiate replication (default).
- --bypassrls
- Allow role to bypass row-level security policies.
- --connection-limit _n_
- Maximum concurrent connections for the role (-1 for unlimited).
- -V, --version
- Print version and exit.
FAQ
What is the createuser command used for?
createuser is a PostgreSQL utility that creates new database users (roles). It's a wrapper around the SQL CREATE ROLE command, providing a convenient command-line interface. The tool can create users with various privileges including superuser status, database creation rights, and role creation abilities. It connects to the database server and executes the appropriate SQL.
How do I run a basic createuser example?
Run `createuser [username]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -s, --superuser do in createuser?
Create superuser.