加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostgreSQL 创建帐号,数据库,权限,备份,恢复

发布时间:2020-12-13 17:43:37 所属栏目:百科 来源:网络整理
导读:创建用户 xxxx1,密码 xxxx,创建数据库 xxxx2,赋予xxxx1 在xxxx2 上的所有权限。 #sudo - s - upostgres $psql postgres# CREATE USER xxxx1 WITH PASSWORD ' xxxx ' ; postgres# CREATE DATABASE xxxx2; postgres# GRANT ALL PRIVILEGES ON DATABASE xxxx
创建用户 xxxx1,密码 xxxx,创建数据库 xxxx2,赋予xxxx1 在xxxx2 上的所有权限。

#sudo-s-upostgres
$psql
postgres#
CREATEUSERxxxx1WITHPASSWORD'xxxx';
postgres#
CREATEDATABASExxxx2;
postgres#
GRANTALLPRIVILEGESONDATABASExxxx2toxxxx1;


备份

pg_dump -h localhost -U Username dbName  -t tableName > ./gps.bak

恢复

psql -h localhost -U UserName -d dbName< ./Desktop/1.backup


从文或流中导入到数据库(copy from)

FOLDER=20120710_new

for file_a in ${FOLDER}/*; do
  cat $file_a|psql -h localhost -U map -d dev -c "copy gps_histories_all (vehicle_no,longitude,latitude,speed,direction,"time") FROM stdin with delimiter ';';"
done

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读