當我嘗試使用 docker 連接到 mysql 時遇到問題。
我的 docker-compose 檔案
version: '2'
services:
app:
build:
context: ./docker/app
dockerfile: Dockerfile
image: ebdaa-m.test.com/app
volumes:
- .:/var/www/html
ports:
- "80:80"
networks:
- sdnet
node:
build:
context: ./docker/node
dockerfile: Dockerfile
image: ebdaa-m.test.com/node
volumes:
- .:/var/www/html
networks:
- sdnet
mysql:
image: mariadb:10.5
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "ecom"
MYSQL_USER: "root"
MYSQL_PASSWORD: "root"
volumes:
- mysqldata:/var/lib/mysql
networks:
- sdnet
redis:
image: redis:alpine
volumes:
- redisdata:/data
networks:
- sdnet
networks:
sdnet:
driver: "bridge"
volumes:
mysqldata:
driver: "local"
redisdata:
driver: "local"
現在,當我撰寫它時,容器就被創建了。我的 docker ps -a 命令給了我以下結果
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5c925d3610c0 ebdaa-m.test.com/node "node" 2 minutes ago Exited (0) 2 minutes ago ebdaa-m-node-1
d001ed99afa4 mariadb:10.5 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:3306->3306/tcp ebdaa-m-mysql-1
7f86bd9a006c ebdaa-m.test.com/app "/usr/bin/supervisord" 2 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp ebdaa-m-app-1
354b5ae00e39 redis:alpine "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 6379/tcp ebdaa-m-redis-1
現在,當我嘗試使用 sequel pro 連接到 mysql 時。我正在傳遞以下憑據以進行連接
Host: 127.0.0.1
User: root
Password: root
Port: 3306
當我嘗試建立連接時出現以下錯誤 -:
Lost connection to MySQL server at 'reading initial communication packet', system error: 0 (2013)
Double-check the MySQL host and port settings are correct, the server is running, and that no firewall settings are blocking access to the server.
If you are connecting through an SSH tunnel, the MySQL host should be the correct address relative to the machine you're SSHing into. Using, for example, the external IP for the MySQL host rather than the local one can often be a source of problems.
請協助。我無法理解可能是什么問題,因為它之前作業正常。
先感謝您。
uj5u.com熱心網友回復:
您聲稱“以前運行良好”。這期間發生了什么?
您可以做的檢查是找出行程是否正在偵聽埠 3306:
netstat -lanp | grep :3306
- 如果輸出為空,請回傳并檢查您的容器,因為該埠上沒有任何內容正在偵聽。
- 如果輸出包含 127.0.0.1 或“任何 IP 通配符”,請再次嘗試連接
- 如果連接包含不是 127.0.0.1 的特定 IP,請使用該 IP 進行連接。
您可能還想檢查您在容器內運行的 mariadb 版本和容器外的 mariadb 客戶端版本是否具有兼容的版本。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/312810.html
標籤:mysql 拉拉维尔 码头工人 docker-compose 玛丽亚数据库
