天天看點

PostgreSQL11.3 建立使用者和建立資料庫

#su root           #切換到root使用者
# su - postgres    #首先切換到postgres
#psql
-bash-4.2$ psql
psql (11.3)
Type "help" for help.
 
postgres=#       

建立使用者

postgres=# create user username with password '****';
CREATE ROLE
postgres=#      

需要注意:

  1. 要以英文分号結尾

  2.密碼需要引号包裹

       3.使用者名首字母不能大寫

建立資料庫

postgres=# create database dbtest owner username;      #建立資料庫指定所屬者
CREATE DATABASE
postgres=#      

将資料庫得權限,全部賦給某個使用者将資料庫得權限,全部賦給某個使用者

postgres=# grant all on database dbtest to username;         #将dbtest所有權限指派給username
GRANT
postgres=#