postgresql导入导出数据;pg_restore: error: did not find magic string in file header
文章目录
- 背景
- 数据导出
- 数据导入
- 针对表格的导入导出,在导入部分要使用pgsql,而不是pg_restore,否则
-
- 解决方式
背景
无法使用DBeaver之后,数据库表的导入导出也变得异常麻烦。
数据导出
PGPASSWORD='你的密码' pg_dump -h 你的数据库IP -U 你的用户名 -d 数据库名 -t 表名 -f 你想导入到哪个文件里的那个文件名.sql
数据导入
PGPASSWORD='你的密码' pgsql -h 你的数据库IP -U 你的用户名 -d 数据库名 -f 上一步的文件名.sql
针对表格的导入导出,在导入部分要使用pgsql,而不是pg_restore,否则
pg_restore: error: options -d/--dbname and -f/--file cannot be used together
pg_restore: hint: Try "pg_restore --help" for more information.
就是说,使用pg_restore都是对整个数据库进行恢复的,所以你不能指定数据库名。
而一旦你不适用数据库名,它又会报错