------ --- 导出 pg_dump -h *.*.*.* -p 5432 -d you_databasename -n you_schema -f you_sqlfile.sql ---- 替换schema 名称 sed -i 's/^SET search_path = oldyou_schemaname, pg_catalog;$/SET search_path = newyou_schemaname, pg_catalog;/' you_sqlfile.sql ---- 没跑过 ----sed -i 's/^oldyou_schemaname.$/newyou_schemaname./' you_sqlfile.sql ---- 导入指定数据库下 psql -d you_databasename -U postgres -f you_sqlfile.sql