创建用户 xxxx1,密码 xxxx,创建数据库 xxxx2,赋予 xxxx1 在 xxxx2 上的所有权限。
# sudo -s -u postgres
$ psql
postgres# CREATE USER xxxx1 WITH PASSWORD 'xxxx';
postgres# CREATE DATABASE xxxx2;
postgres# GRANT ALL PRIVILEGES ON DATABASE xxxx2 to xxxx1;
备份
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