postgresql新建使用者和資料庫

2021-09-29 09:31:11 字數 633 閱讀 5724

postgresql新建使用者和資料庫

一、問題描述

安裝postgresql後,資料庫服務會有三個庫。postgres、template0、template1。在實際使用中,我們不會使用這三個庫,也不會使用超級使用者來對資料庫進行操作。

一般是建立乙個具有登入許可權的使用者,並建立乙個資料庫,讓建立的新使用者具有操作新建的資料庫的許可權。

二、具體操作步驟

建立具有登入許可權的使用者

create

user newuser with password 'new123456'

;

建立資料庫,設定owner為新建的使用者

create

database newdb owner newuser;

讓新建使用者具有操作新建資料庫的許可權

grant

allprivileges

ondatabase newdb to newuser;

三、常用命令

更改使用者密碼sql:

alter username with password 'newpassword'

;

mysql 新建使用者和授權

一,建立使用者 命令 create user username host identified by password 說明 username 你將建立的使用者名稱,host 指定該使用者在哪個主機上可以登陸,如果是本地使用者可用localhost,如果想讓該使用者可以從任意遠端主機登陸,可以使用萬...

linux新建使用者組和使用者

該文章所有操作都在root許可權下完成的。新建使用者組 命令 groupadd 選項 使用者組 引數 g gid 指定新使用者組的組標識號 gid o 一般與 g選項同時使用,表示新使用者組的gid可以與系統已有使用者組的gid相同。新建使用者 命令 useradd 選項 使用者名稱 引數 c co...

PostgreSQL安裝和建立使用者和建立資料庫

可以參考postgresql官網安裝教程 su postgres 首先切換到postgres bash 4.1 psql 輸入psql psql 10.5 type help for help.postgres 建立使用者 postgres create user username with pas...