语境
我已经使用APT 安装步骤在Ubuntu 18.04(默认软件包没有这个新的 apt 存储库管理组在版本 3 中,该功能已被弃用)。
当我使用 pgadmin 服务器图标托盘中的“配置...”菜单打开时,我的配置面板如下所示;
这似乎与文件的内容相匹配~/.config/pgadmin/pgadmin4.conf
:
$ cat ~/.config/pgadmin/pgadmin4.conf
[General]
ApplicationPath=
BrowserCommand=/usr/bin/brave-browser --private %URL%
FixedPort=true
OpenTabAtStartup=false
PortNumber=5433
PythonPath="/usr/local/lib/python3.6/dist-packages;/usr/lib/python3/dist-packages;/usr/local/lib/python3.6/dist-packages"
错误
现在,如果我pgadmin4
在控制台中启动,我会得到这个(启动需要几秒钟,因此一开始会出现多个相同的失败消息):
$ pgadmin4
QCoreApplication::applicationFilePath: Please instantiate the QApplication object first
QCoreApplication::applicationFilePath: Please instantiate the QApplication object first
Semaphore name: "pgadmin4-<user>-3ed67051278d25124b2c63f6651290d1-sema"
Shared memory segment name: "pgadmin4-<user>-3ed67051278d25124b2c63f6651290d1-shmem"
Python path: "/usr/local/lib/python3.6/dist-packages:/usr/lib/python3/dist-packages:/usr/local/lib/python3.6/dist-packages"
Python Home: ""
Webapp path: "/usr/share/pgadmin4/web/pgAdmin4.py"
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Failed to connect to the server: "Connection refused" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
Server response: "PING" - request URL: "http://127.0.0.1:39931/misc/ping?key=28059bf0-430c-4759-a9c2-1b05e1b67a02" .
它会自动打开一个新的火狐标签,我要求它打开一个新的勇敢的浏览器处于私人模式选项卡。
问题
那里出了什么问题,我该如何修复它(例如强制 pgadmin4 在勇敢的私人标签页)?
我还希望能够从 ubuntu TTY(Ctrl+ F1,而不是 GUI 控制台)启动 pgAdmin4,因此告诉它启动没有启动任何类型的浏览器,但我遇到了很多 QT 错误)。
答案1
作为一种解决方法,我构建了一个 docker-compose 文件(基于此图像);https://hub.docker.com/r/dpage/pgadmin4/如此处所述:https://www.pgadmin.org/download/pgadmin-4-container/)如下,以便能够连接到我本地机器上托管的数据库:
version: '3.8'
services:
pgadmin4:
image: dpage/pgadmin4
container_name: pgadmin4
environment:
- [email protected]
- PGADMIN_DEFAULT_PASSWORD=password
- PGADMIN_LISTEN_PORT=5050
ports:
- "5050:5050"
network_mode: host
只需启动它# docker-compose up -d
并跟踪日志# docker-compose logs --tail 10 -f
浏览 http://localhost:5050 并使用编写环境变量你已经选择。
不要忘记network_mode: host
能够连接到本地数据库。另外请记住,如果您插入其他服务,您可能希望保持网络隔离安全,因此请务必确保您正在做的事情。
如果你需要连接到远程服务器,这是可能的;在这种情况下,你需要打开一个SSH 隧道在 pgAdmin4 中设置连接之前。我还必须postgres
在远程计算机之外创建一个 PostgreSQL 用户,以便使用密码进行连接(postgres
在远程计算机上使用对等连接,我确信这是通过远程访问进行的)。
该解决方案可能会随着时间的推移而发展,因为它依赖于 pgAdmin 4.29 的预版本,如下所示:
https://www.pgadmin.org/docs/pgadmin4/development/container_deployment.html