创建用户 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