天天看点

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=#