2、postgres数据导入

发布时间 2023-08-23 16:53:50作者: 站着说话不腰疼

postgres数据导入

1、数据导入

psql -f user_export.sql -h localhost -U mypguser -W mypostgres

参数说明:

-f 读取的sql文件

-h 导入的ip地址

-U 导入的用户

-W 导入指定的数据库

2、导入不存在数据库处理

createdb -U postgres -h localhost mypostgres

然后在执行导入

3、整库导入

psql -U postgres -d mypostgres -f /home/postgres/export.sql

-U :后面指定的是有数据库操作权限的用户
-d:后面指定的是数据库中的一个库名
-f:后面指定的是sql文件存放的路径。