docker-compose: mariadb - Connection refused

别等时光非礼了梦想. 提交于 2020-01-25 09:21:06

问题


Step 1) mysql5 & 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"

I can access my mysql-database via phpmyadmin: http://localhost:3333/

Step 2) mysql8 & phpmyadmin

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"

I can access my mysql-database via phpmyadmin: http://localhost:3333/

Step 3) mariadb & phpmyadmin

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"

Now I cannot access my mariadb-database via phpmyadmin:

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?


回答1:


Your docker-compose file works. I start MySQL container than switch to MariaDB image and it's working fine. I think you should look into docker logs. The answer is there




回答2:


MariaDB doesn't have default-authentication-plugin option. That might be the reason




回答3:


It works for mariadb with --default-authentication-plugin=mysql_native_password, just the container start is really slow.

[Edit] Here is a MWE, which works with different mysql-versions (5 and 8) and the newest mariadb (10):

  • https://github.com/boldt/docker-compose-mariadb-mysql-phpmyadmin


来源:https://stackoverflow.com/questions/58577255/docker-compose-mariadb-connection-refused

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!