tips:--insert方式备份的sql文件可以直接用输入重定向进行还原: psql 库名 -U 用户名 <备份文件名.sql 如: psql ierp_sys -U cosmic < /data/ierp_sys.sql 2.1 还原单个数据库(需指定数据库) pg_restore 可以从pg_dump创建的存档中恢复一个PostgreSQL数据库。常用参数如下: ...
log"info""开始恢复数据库,使用备份文件:$selected_file"local restore_command="PGPASSWORD=$PG_PASSWORD gunzip -c $selected_file | psql -U $PG_USER -h $PG_HOST -p $PG_PORT"bash-c"$restore_command"if[ $? -eq0];thenlog"info""数据库恢复成功:$DB_NAME"elselog"error""数据库恢复失败"fi...
-Ft 为压缩为tar模式 只能用pg_restore恢复 备份: pg_dump -U postgres -Ft tdcb_all>tdcb_all.tar 1. 恢复: pg_restore -U postgres -d tdcb_all_new< d:\tdcb_all.tar 1. pg_restore -U postgres -d tdcb_all_new d:\tdcb_all.tar >a.txt 2>&1 1. 具体例子: 备份: d:\apps\Post...
pg_restore -h 127.0.0.1 -p 5432 -U postgres -W -d postgres < D:\postgres.bak pg_restore -h 127.0.0.1 -U postgres -W -d postgres -n schema1 < D:\postgres.bak 2、还原sql文本文件 psql -h 127.0.0.1 -U postgres -d postgres < D:\postgres.bak === 问题: 1、乱码 打开cmd窗口,直...
pg_restore 使用pg_restore纯文本恢复纯文本格式的脚本,无法恢复 [root@localhost postgres-9.3.5]# pg_restore -U postgres -d bk01 /mnt/hgfs/window\&ubuntu\ shared\ folder/vendemo.sql pg_restore: [archiver] input file appears to be a text format dump. Please use psql. ...
例如,命令可以是: pg_restore -h localhost -p 5432 -U postgres -d postgres -C -v /path/to/backup_file 执行命令后,系统会提示输入密码,输入正确的密码后,开始恢复数据库。 等待恢复过程完成,恢复过程的时间长度取决于备份文件的大小和系统性能。
-f, --file=FILENAME 导出后保存的文件名 -j, --jobs=NUM 指定备份的并行度,指定备份路径而非备份文件,会生成很多小文件,还原时指定该目录即可 --insert 导出成sql语句类型,虽然方便查看数据内容...
-f file --file=file 把输出发往指定的文件。如果忽略这些,则使用标准输出。 -F format --format=format 选择输出的格式。format可以是下列之一: p 输出纯文本SQL脚本文件(缺省) t 输出适合输入到 pg_restore 里的tar归档文件。 使用这个归档允许在恢复数据库时重新排序和/或把数据库对象排除在外。 同时也可能...
postgres=# \help // 获取SQL命令的帮助,同 \h postgres=# \quit // 退出,同 \q postgres=# \password dlf // 重新设置用户dlf的密码,然后需要 \q退出后才生效 c:\>psql exampledb < user.sql // 将user.sql文件导入到exampled数据库中 postgres=# \h select // 精细显示SQL命令中的select命令的使...
1. psql:这是PostgreSQL交互式终端命令行工具,用于连接并与数据库进行交互。可以使用它执行SQL查询、创建表、插入数据等。使用方法:psql -U {用户名} -h {主机名} -d {数据库名}。 2. createdb:用于在PostgreSQL中创建新的数据库。使用方法:createdb -U {用户名} -h {主机名} -p {端口号} {数据库名...