pg_dump:

pg_dump -a -t tbl_test "host=127.0.0.1 hostaddr=127.0.0.1 port=5432 user=postgres password=123456 dbname=postgres" > /userdir/tbl_data

-a 参数是表示只导出数据,其他的额外信息不需要,该参数也可去掉

psql:

psql --command "select * from tbl_test;" "host=127.0.0.1 hostaddr=127.0.0.1 port=5432 user=postgres password=123456 dbname=postgres"

 

当然可以使用export(linux平台)将数据库的相关配置设置到环境变量中,可以设置的变量如下(除过PGPASSWORD外,其他的没验证,不过理论上应该可以的):

  1.  
    export PGHOST='localhost'
  2.  
    export PGUSER=postgres
  3.  
    export PGDATABASE=postgres
  4.  
    export PGPASSWORD=null
  5.  
    export PGPORT=5432

 

相关文章:

  • 2022-12-23
  • 2021-09-11
  • 2021-06-19
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-13
  • 2021-07-14
  • 2022-12-23
  • 2022-01-24
  • 2021-12-31
  • 2022-12-23
相关资源
相似解决方案