docker-compose:mariadb-连接被拒绝 [英] docker-compose: mariadb - Connection refused
问题描述
步骤1)mysql5& phpmyadmin
映像以下mysql-phpmyadmin配置:
Image the following mysql-phpmyadmin configuration:
version: '3.6'
services:
db:
image: mysql:5.7.24
# image: mysql:8.0.18
# image: mariadb:10.4.8
# command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
- ./mysql5:/var/lib/mysql
# - ./mysql8:/var/lib/mysql
# - ./mariadb:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=test
- MYSQL_DATABASE=test
- MYSQL_USER=test
- MYSQL_PASSWORD=test
phpmyadmin:
image: phpmyadmin/phpmyadmin:4.8.5
restart: always
depends_on:
- db
environment:
- PMA_HOST=db
- PMA_PORT=3306
- PMA_USER=test
- PMA_PASSWORD=test
ports:
- "3333:80"
我可以通过phpmyadmin访问我的 mysql数据库: http://localhost:3333/
I can access my mysql-database via phpmyadmin: http://localhost:3333/
步骤2)mysql8& phpmyadmin
现在,我切换到mysql8,在这里我仅使用映像和卷,并在command
-option中添加了mysql_native_password
-plugin:
Now I switch to mysql8, where I only the image and volume and added the command
-option with the mysql_native_password
-plugin:
version: '3.6'
services:
db:
# image: mysql:5.7.24
image: mysql:8.0.18
# image: mariadb:10.4.8
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
# - ./mysql5:/var/lib/mysql
- ./mysql8:/var/lib/mysql
# - ./mariadb:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=test
- MYSQL_DATABASE=test
- MYSQL_USER=test
- MYSQL_PASSWORD=test
phpmyadmin:
image: phpmyadmin/phpmyadmin:4.8.5
restart: always
depends_on:
- db
environment:
- PMA_HOST=db
- PMA_PORT=3306
- PMA_USER=test
- PMA_PASSWORD=test
ports:
- "3333:80"
我可以通过phpmyadmin访问我的 mysql数据库: http://localhost:3333/
I can access my mysql-database via phpmyadmin: http://localhost:3333/
步骤3)mariadb& phpmyadmin
现在,我使用以下配置切换到mariadb,在该配置中,我仅更改了图像和音量:
Now I switch to mariadb with the following configuration, where I only changed the image and volume:
version: '3.6'
services:
db:
# image: mysql:5.7.24
# image: mysql:8.0.18
image: mariadb:10.4.8
command: --default-authentication-plugin=mysql_native_password
restart: always
volumes:
# - ./mysql5:/var/lib/mysql
# - ./mysql8:/var/lib/mysql
- ./mariadb:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=test
- MYSQL_DATABASE=test
- MYSQL_USER=test
- MYSQL_PASSWORD=test
phpmyadmin:
image: phpmyadmin/phpmyadmin:4.8.5
restart: always
depends_on:
- db
environment:
- PMA_HOST=db
- PMA_PORT=3306
- PMA_USER=test
- PMA_PASSWORD=test
ports:
- "3333:80"
现在我无法通过phpmyadmin访问我的 mariadb数据库:
Now I cannot access my mariadb-database via phpmyadmin:
在 docker hub 上执行mariadb-README之后,环境配置应与用于mysql5-container.我认为,我还需要启用mysql_native_password
,该功能对于mysql8-container无效.
Following the mariadb-README on docker hub, the environment configuration should be the same as for the mysql5-container. I assume, that I also need to enable the mysql_native_password
, which does not work as for the mysql8-container.
我想念什么?这是一个错误还是我错过了什么?
What do I miss? Is this a bug or do I miss something?
推荐答案
它适用于mariadb
和--default-authentication-plugin=mysql_native_password
,只是容器的启动确实很慢.
It works for mariadb
with --default-authentication-plugin=mysql_native_password
, just the container start is really slow.
这是一个MWE,可与不同的mysql版本(5和8)和最新的mariadb(10)一起使用:
Here is a MWE, which works with different mysql-versions (5 and 8) and the newest mariadb (10):
这篇关于docker-compose:mariadb-连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!