且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

解决 dropdb: could not connect to database postgres: could not connect to server:

更新时间:2022-02-12 00:14:49

今天在调试一个脚本的时候遇到这个错误:

dropdb: could not connect to database postgres: could not connect to server: 

这个脚本调用了postgresql的dropdb命令。

找了下资料似乎是dropdb时候找的库不对导致的。 由于这个脚本以前是对本机postgreSQL操作的,这次是对remote的postgreSQL操作的,所以测试了一下差异:

./dropdb -U postgres mydbase 默认对本机数据库操作

./dropdb -U postgres dsvdbase -h 10.**.**.**  加上了IP地址,对此IP的数据库操作

 

所以由于脚本所在服务器没有装postgreSQL,出了错, 给这个脚本填加-h解决