一、建立使用者
二、建立資料庫# 切換到postgres使用者
sudo su - postgres
# 建立使用者
create user dbuser with password '123456';
create database testdb owner dbuser;
三、將testdb資料庫的所有許可權都賦予使用者dbuser,然後\q退出grant all privileges on database testdb to dbuser;
四、建立linux使用者五、以後登入資料庫sudo adduser dbuser
sudo passwd dbuser
六、一些資料庫命令# 切換使用者
su - dbuser
# 登入指定資料庫
psql -d testdb
參考鏈結# 檢視所有資料庫
\l# 選擇資料庫
\c testdb
# 檢視表
\d# 退出
\q
postgresql 資料庫基本操作
c dbname 切換資料庫,相當於mysql的use dbname l 列舉資料庫,相當於mysql的show databases dt 列舉表,相當於show tables d tblname 檢視表結構,相當於desc tblname,show columns from tbname 一般性c...
PostgreSQL操作 psql基本命令
一 建立資料庫連線 接入postgresql資料庫 psql h ip位址 p 埠 u 連線使用者名稱 之後會要求輸入資料庫密碼 二 訪問資料庫 1 列舉資料庫 l 2 選擇資料庫 c 資料庫名 3 檢視該某個庫中的所有表 dt 4 切換資料庫 c inte ce 5 檢視某個庫中的某個表結構 d ...
PostgreSQL基本用法
sudo apt get install postgresql client sudo apt get install postgresql sudo service postgresql start sudo u postgres psqlpostgres postgres password po...