在 QNAP NAS 中,有一个 MySQL Docker 容器,其中包含:
创建 phpMyAdmin Docker 容器时,我指定:
但是加载phpMyAdmin时,出现错误:
Cannot connect: invalid settings.
mysqli::real_connect(): Premature end of data (mysqlnd_wireprotocol.c:387)
mysqli::real_connect(): GREET packet 4 bytes shorter than expected
mysqli::real_connect(): Error while reading greeting packet. PID=30
mysqli::real_connect(): (HY000/2002): Unknown error while trying to connect via tcp://10.0.3.3:33060
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
我猜问题是默认端口是
3306
但你有 33060
,所以它甚至没有启动连接,因为你在消息中服务器拒绝了连接。它被拒绝,因为它没有监听该端口
附加说明查看https://hub.docker.com/_/mysql,没有有关MySQL默认端口的信息,因此我们可以通过例如Google
What is default port for MySQL server
获取它,我们也可以访问Docker Hub 上的特定镜像标签mysql:latest并查找命令EXPOSE
,在这种情况下我们将得到EXPOSE map[3306/tcp:{} 33060/tcp:{}]
。
这里要提到的额外事情是端口
33060
,但是我更深入地了解它,我们会得到它是 Port X Portocol,这不是 phpMyAdmin 所期望的(这是我从中学到的)