我在amazone ec2上有一个正在运行的postgresql服务器。我通过pgAdmin3在我的Mac中直接配置的ssh隧道将pgAdmin3连接到它。
我可以进行查询并看到完整的架构,对此没有任何问题。
如果我尝试从pgAdmin3 GUI备份数据库,那么我将获得以下异常(即使该连接实际上已打开并正在工作):
/Applications/pgAdmin3.app/Contents/SharedSupport/pg_dump --host localhost --port 5432 --username "MY_USERNAME" --role "MY_ROLE" --no-password --format custom --encoding UTF8 --verbose --file "/Users/XXX/filename" "DATABASENAME"
pg_dump: [archiver (db)] connection to database "DATABASENAME" failed: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
Process ended with Exitcode 1.
知道为什么后台的pg_dump无法通过ssh隧道连接吗?
最佳答案
直到我找到一个解决方案是通过终端使其替代
ssh <HOST> "pg_dump -U <USERNAME> -W -h localhost -F c <DATABASENAME> | gzip -c" > ./backup.sql.gz
关于postgresql - pgAdmin3通过ssh隧道备份,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32398311/