NiL*_*iLL 13 postgresql dump psql
我需要在控制台工具中恢复PostgreSQL数据库中的一个大表(250mb).我怎么能用ps_dump或psql做到这一点?
psql --username yourusername --dbname yourdatabasename -f yourfile.sql
Run Code Online (Sandbox Code Playgroud)
为澄清这里.根据配置,可能会要求您输入密码.
如果它是一个没有数据库的新安装的数据库引擎,请使用postgres
数据库名称并尝试省略用户名部分(新安装通常应授予对安装它的当前用户的完全访问权限).
如果仍然无法登录,请临时编辑pg_hba.conf,无论它在您的安装中的哪个位置,并暂时将localhost设置为trusted.然后,您可以将postgres指定为用户名和数据库名称.
完成后不要忘记恢复pg_hba.conf更改.
psql dbname < /path/to/dump.sql
Run Code Online (Sandbox Code Playgroud)
如果需要,您甚至可以即时修改您的转储:
sed 's/OWNER TO olduser/OWNER TO newuser/g' < /path/to/dump.sql | psql dbname
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
34423 次 |
最近记录: |