PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔媆誕嬉誕

createuser

劉䓄

createuser -- 垔幬婔婻桄䫘潙婊潙

臺濘

createuser [option...] [username]

柟誄

createuser 录傺婔婻桄䔇 PostgreSQL 䫘潙(敘庖䇞婄臘滇婔婻蓐謾)㔗埻橬轙亓䫘潙启橬 CREATEROLE 溄鍊䔇䫘潙埇傖录傺桄䔇䫘潙㔗啹溴createuser 媙釂䫌轙亓䫘潙潡蔙滇橬 CREATEROLE 溄鍊䔇䫘潙欓臯㔗

套悩嘹婯橕录傺婔婻桄䔇轙亓䫘潙嘹媙釂傖轙亓䫘潙躆傘誂毖蔯婉備備滇婔婻橬 CREATEROLE 溄鍊䔇䫘潙㔗潊婺轙亓䫘潙儌懟叿五儖婘昄扞康麯䂘嚔欔橬螪閞溄鍊演昖啹溴婉襕蘂滷蕋庽轙亓䫘潙溄鍊㔗

createuser 滇 SQL 变傴 CREATE ROLE 䔇儕輙㔗啹溴認婴䓉桹濘录傺䔇桄䫘潙澇傔幽噞彆㔗

锬釹

createuser 毖埖婋彖变傴臯埗昄

username

襕录傺䔇 PostgreSQL 蓐謾劉䓄㔗臖劉䓄媙釂婘臖 PostgreSQL 垬輙䔇欔橬蓐謾婺嫇婔㔗

-s
--superuser

臘滯桄䫘潙儖滇轙亓䫘潙

-S
--no-superuser

桄䫘潙儖婉滇轙亓䫘潙㔗認婻滇䚺䩕㔗

-d
--createdb

噕螩臖桄傺䫘潙录傺昄扞康

-D
--no-createdb

䥕溵臖桄傺䫘潙录傺昄扞康㔗認婻滇䚺䩕㔗

-r
--createrole

T桄䫘潙儖赆噕螩录傺桄蓐謾幘儌滇臘認婻䫘潙儖橬 CREATEROLE 溄鍊㔗

-R
--no-createrole

桄䫘潙儖婉噕螩录傺桄蓐謾㔗認婻滇䚺䩕㔗

-l
--login

桄䫘潙儖噕螩䍂嘘幘儌滇臘䫘潙劉埇傖䫘嘩彺哋嚔臺䔇䫘潙湺臖㔗認婻滇䚺䩕㔗

-L
--no-login

桄䫘潙儖婉噕螩䍂嘘㔗婔婻婉脘䍂嘘䔇蓐謾傉䇽滇冽橬䫘䔇懫套䫘庯溄鍊䞇䊖㔗

-i
--inherit

桄蓐謾儖躻媘䂓欪噽欔匂蓐謾䂇䔇溄鍊㔗認婻滇䚺䩕㔗

-I
--no-inherit

桄蓐謾儖婉嚔躻媘䂓欪傡欔匂蓐謾䂇䔇溄鍊㔗

-c number
--connection-limit number

婺桄䫘潙螆䘞橔崓昄䕞䔇誂毖昄㔗䚺䩕婺方鍊彽㔗

-P
--pwprompt

套悩䂍庺createuser 儖埏庺婔婻柊䴺严襕挗膷噖桄䫘潙䔇埼傴㔗套悩嘹婉欷䞖䫘埼傴螴臕闼幽認滇婉媙襕䔇㔗

-E
--encrypted

凹䫘潙庻嗘婘昄扞康麯䔇埼傴誕臯媹凖㔗套悩澇橬弄滯嘪䫘䚺䩕䔇埼傴臯婺㔗

-N
--unencrypted

婉襕媹凖䫘潙庻嗘婘昄扞康麯䔇埼傴㔗套悩澇橬弄滯嘪䫘䚺䩕䔇埼傴臯婺㔗

-e
--echo

啂滆 createuser 䫘潊幽埏锕彄橉媇単䔇变傴㔗

-q
--quiet

婉滆䴺橉媇単庫享(垬麍昇嚟)

套悩澇橬婘变傴臯婪弄滯媙釂䔇媇敇䘋废嚔柊䴺嘹膷噖㔗

createuser 誻毖埖婋彖变傴臯埗昄嘩婺誂毖埗昄

-h host
--host host

毺垔誊臯橉媇単䔇婂橺劉㔗套悩昄唚傖桩溹嚔崘彍赆䫘嘩彄 Unix 嘘喖毖庖䔇虇冇㔗

-p port
--port port

毺垔橉媇単溼婘冥劸䔇 TCP 䆇埼潡橸婄 Unix 嘘喖毖庖桺傽䔇欷匘(柟誄严)

-U username
--username username

誂毖䔇䫘潙劉(婉滇襕录傺䔇䫘潙劉)

-W
--password

嚺彽埼傴柊䴺(婯橉媇単誂毖䔇埼傴蔯婉滇桄䫘潙䔇埼傴)

䯇嵄埻麟

PGHOST
PGPORT
PGUSER

䚺䩕誂毖埗昄

自桺

套悩庺䯄閞鵻儖嚔滆䴺劯䆇髍臇媇敇㔗埗黙 CREATE ROLEpsql 诙埡埇䫘媇敇䔇柟誄㔗昄扞康橉媇単媙釂婘䕞湺婂橺婪誊臯㔗劯湙傂嘘 libpq 嬉䆇康嘪䫘䔇䚺䩕誂毖螆䘞启䯇嵄埻麟鄘儖锗䫘㔗

冋床

婘䚺䩕昄扞康橉媇単婪录傺婔婻 joe 䫘潙

$ createuser joe
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
CREATE USER

䫘婘婂橺 eden 婪䔇橉媇単麯录傺 joe 䫘潙䆇埼滇 5000 镪噉柊䴺幽婫啂滆欓臯䔇变傴

$ createuser -h eden -p 5000 -S -D -R -e joe
CREATE ROLE joe NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;
CREATE ROLE

檪䫘潙 joe 录傺婺轙亓䫘潙幽婫䆋剿蕋庽埼傴

$ createuser -P -s -e joe
Enter password for new role: xyzzy
Enter it again: xyzzy
CREATE ROLE joe PASSWORD 'xyzzy' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;
CREATE ROLE

婘婪麵冋床婺荘䇽桄埼傴婘膷噖䔇施唍垂鍙婪幽婉嚔垂鍙滆䴺庺準嘖滇潏傸誻滇滯䇞䔇檪垄滆䴺庺準庖㔗䇽蔯埼傴嚔婘啂滆䔇变傴麯滆䴺庺準溼套婪麵滆䴺䔇闼湙啹溴婘毺垔埼傴䔇施唍潏傸埉凹嘹婘彆庺埇傖䩋蓕嘹䔇匟幘䔇愙喕婋嘪䫘 -e 锬釹㔗

埽蓕

dropuser, CREATE ROLE, 䯇嵄埻麟(誗29.12)

劯锔饡釕嬉誕
createlang婪婔亓dropdb