[root@localhost ~]# su postgres 切换用户
bash-4.2$ psql
could not change directory to "/root": Permission denied
psql (9.5.6)
Type "help" for help.
postgres=# psql -Upostgres
postgres-# psql -Upostgres</root/Desktop/db.sql 我的脚本在桌面
==================
[root@localhost dreamstart]
# su postgres
bash
-4.2$ psql -Upostgres<db.sql
参看http://www.cnblogs.com/Amos-Turing/p/6862253.html