如果数据从本地导入到远端的话,可通过建立ssh隧道,使用本地端口即可连接远端数据库,使用起来更加方便快捷,命令如下:
#-C表示请求压缩所有数据,默认使用gzip
ssh -C -L local_port:localhost:remote_port remote_user@remote_ip
实例:
#建立ssh隧道
ssh -C -L 66666:localhost:1921 root@8.1xx.2xx.9x
#另外在本地shell使用该端口可连接远端的数据库
psql -h 127.0.0.1 -p 66666 -U postgres postgres
参考:
https://www.postgresql.org/docs/13/ssh-tunnels.html