📄 createuser.1
字号:
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "CREATEUSER" "1" "2008-01-03" "Application" "PostgreSQL Client Applications".SH NAMEcreateuser \- define a new PostgreSQL user account.SH SYNOPSIS.sp\fBcreateuser\fR [ \fB\fIoption\fB\fR\fI...\fR ] [ \fB\fIusername\fB\fR ] .SH "DESCRIPTION".PP\fBcreateuser\fR creates a new PostgreSQL user (or more precisely, a role).Only superusers and users with CREATEROLE privilege can createnew users, so \fBcreateuser\fR must beinvoked by someone who can connect as a superuser or a user withCREATEROLE privilege..PPIf you wish to create a new superuser, you must connect as asuperuser, not merely with CREATEROLE privilege.Being a superuser implies the ability to bypass all access permissionchecks within the database, so superuserdom should not be granted lightly..PP\fBcreateuser\fR is a wrapper around theSQL command CREATE ROLE [\fBcreate_role\fR(7)].There is no effective difference between creating users viathis utility and via other methods for accessing the server..SH "OPTIONS".PP\fBcreateuser\fR accepts the following command-line arguments:.TP\fB\fIusername\fB\fRSpecifies the name of the PostgreSQL userto be created.This name must be different from all existing roles in thisPostgreSQL installation..TP\fB-s\fR.TP\fB--superuser\fRThe new user will be a superuser..TP\fB-S\fR.TP\fB--no-superuser\fRThe new user will not be a superuser.This is the default..TP\fB-d\fR.TP\fB--createdb\fRThe new user will be allowed to create databases..TP\fB-D\fR.TP\fB--no-createdb\fRThe new user will not be allowed to create databases.This is the default..TP\fB-r\fR.TP\fB--createrole\fRThe new user will be allowed to create new roles (that is,this user will have CREATEROLE privilege)..TP\fB-R\fR.TP\fB--no-createrole\fRThe new user will not be allowed to create new roles.This is the default..TP\fB-l\fR.TP\fB--login\fRThe new user will be allowed to log in (that is, the user namecan be used as the initial session user identifier).This is the default..TP\fB-L\fR.TP\fB--no-login\fRThe new user will not be allowed to log in.(A role without login privilege is still useful as a means ofmanaging database permissions.).TP\fB-i\fR.TP\fB--inherit\fRThe new role will automatically inherit privileges of rolesit is a member of.This is the default..TP\fB-I\fR.TP\fB--no-inherit\fRThe new role will not automatically inherit privileges of rolesit is a member of..TP\fB-c \fInumber\fB\fR.TP\fB--connection-limit \fInumber\fB\fRSet a maximum number of connections for the new user.The default is to set no limit..TP\fB-P\fR.TP\fB--pwprompt\fRIf given, \fBcreateuser\fR will issue a prompt forthe password of the new user. This is not necessary if you do not planon using password authentication..TP\fB-E\fR.TP\fB--encrypted\fREncrypts the user's password stored in the database. If notspecified, the default password behavior is used..TP\fB-N\fR.TP\fB--unencrypted\fRDoes not encrypt the user's password stored in the database. Ifnot specified, the default password behavior is used..TP\fB-e\fR.TP\fB--echo\fREcho the commands that \fBcreateuser\fR generatesand sends to the server..TP\fB-q\fR.TP\fB--quiet\fRDo not display a response..PP.PPYou will be prompted for a name and other missing information if itis not specified on the command line..PP\fBcreateuser\fR also accepts the followingcommand-line arguments for connection parameters:.TP\fB-h \fIhost\fB\fR.TP\fB--host \fIhost\fB\fRSpecifies the host name of the machine on which the serveris running. If the value begins with a slash, it is used as the directory for the Unix domain socket..TP\fB-p \fIport\fB\fR.TP\fB--port \fIport\fB\fRSpecifies the TCP port or local Unix domain socket file extension on which the serveris listening for connections..TP\fB-U \fIusername\fB\fR.TP\fB--username \fIusername\fB\fRUser name to connect as (not the user name to create)..TP\fB-W\fR.TP\fB--password\fRForce password prompt (to connect to the server, not for thepassword of the new user)..PP.SH "ENVIRONMENT".TP\fBPGHOST\fR.TP\fBPGPORT\fR.TP\fBPGUSER\fRDefault connection parameters.PPThis utility, like most other PostgreSQL utilities,also uses the environment variables supported by \fBlibpq\fR(see in the documentation)..PP.SH "DIAGNOSTICS".PPIn case of difficulty, see CREATE ROLE [\fBcreate_role\fR(7)] and \fBpsql\fR(1) fordiscussions of potential problems and error messages.The database server must be running at thetargeted host. Also, any default connection settings and environmentvariables used by the \fBlibpq\fR front-endlibrary will apply..SH "EXAMPLES".PPTo create a user joe on the default databaseserver:.sp.nf$ \fBcreateuser joe\fRShall the new role be a superuser? (y/n) \fBn\fRShall the new role be allowed to create databases? (y/n) \fBn\fRShall the new role be allowed to create more new roles? (y/n) \fBn\fRCREATE USER.sp.fi.PPTo create the same user joe using theserver on host eden, port 5000, avoiding the prompts andtaking a look at the underlying command:.sp.nf$ \fBcreateuser -h eden -p 5000 -S -D -R -e joe\fRCREATE ROLE joe NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;CREATE ROLE.sp.fi.PPTo create the user joe as a superuser,and assign a password immediately:.sp.nf$ \fBcreateuser -P -s -e joe\fREnter password for new role: \fBxyzzy\fREnter it again: \fBxyzzy\fRCREATE ROLE joe PASSWORD 'xyzzy' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;CREATE ROLE.sp.fiIn the above example, the new password isn't actually echoed when typed,but we show what was typed for clarity. However the password\fBwill\fR appear in the echoed command, as illustrated \(emso you don't want to use -e when assigning a password, ifanyone else can see your screen..SH "SEE ALSO"\fBdropuser\fR(1), CREATE ROLE [\fBcreate_role\fR(7)]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -