MariaDB / mariadb-docker

Docker Official Image packaging for MariaDB
https://mariadb.org
GNU General Public License v2.0
770 stars 438 forks source link

[SOLVED] Not able to connect via phpMyAdmin on Synology NAS #310

Closed networkpotato closed 4 years ago

networkpotato commented 4 years ago

I try to run mariadb in Docker on my Synology NAS using this command and it appears to work fine:

docker run --name mariadb -v /volume1/docker/mariadb:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=xxx -d mariadb:latest

I also run phpMyAdmin in Docker: docker run --name phpmyadmin -d --link mariadb:db -p 84:80 -v /volume1/docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php phpmyadmin/phpmyadmin

When I try to log in through phpMyAdmin I get these errors:

error

And this line in the mariadb log:

[Warning] Aborted connection 8 to db: 'unconnected' user: 'unauthenticated' host: '172.17.0.5' (This connection closed normally without authentication)

If I use the MariaDB package from the Synology Package Center and use PMA_HOST=IP:PORT in phpMyAdmin it works perfectly.

But I would like to also have the db in Docker if possible.

wglambert commented 4 years ago

Looks like a duplicate of https://github.com/docker-library/mariadb/issues/264

networkpotato commented 4 years ago

Looks like a duplicate of #264

I tried adding --default-authentication-plugin=mysql_native_password to my command, but nothing happened, beside a line in the log that says it's a feature of mysql that hasn't been implemented yet.

Other than that, I can't see any other differences between my command and the one that resolved the problem in #264 ?

wglambert commented 4 years ago

I didn't have any issues using the docker-compose.yml in that thread https://github.com/docker-library/mariadb/issues/264#issuecomment-546668998

image

networkpotato commented 4 years ago

Pretty sure I can't do that on Synology?

wglambert commented 4 years ago

Well the issue seems to be something with your host's environment or a configuration issue, and without a practical reproducer there's no method for us to troubleshoot by

You could also try asking over at the Docker Community Forums, Docker Community Slack, or Stack Overflow. Since these repos aren't really a user-help forum

AbDhops commented 4 years ago

@evadue Did you resolved the issue ? How... ?

networkpotato commented 4 years ago

@evadue Did you resolved the issue ? How... ?

No, I gave up. I don't know where to go from here..

networkpotato commented 4 years ago

SOLVED!

After a couple more hours of Googling I came across this thread.

What I had to do was to create a file called config.inc.php and map it up with the container:

-v /volume1/docker/phpmyadmin/config.inc.php:/etc/phpmyadmin/config.inc.php

And add the following content to the file

And it just worked like that!

AbDhops commented 4 years ago

Wowwwwwwwwww... Will try and let you know...

AbDhops commented 4 years ago

Well, I tried exact steps as you mentioned. However, issue is still same. See below my docker compose file. Do you see any error ?

version: "3.7"

# to Enter in docker 
# docker exec -it MariaDB bash
# docker logs mariadb
services:
  db:
    image: mariadb
    container_name: MariaDB
    restart: always
    environment:
    - MYSQL_ROOT_PASSWORD=test
    volumes:
    - './database:/var/lib/mysql'
    - /etc/localtime:/etc/localtime:ro

# docker exec -it MyPhpAdmin bash
  myphpadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: MyPhpAdmin
    restart: always
    hostname: phpadmin.test.com
    depends_on:
    - db
    volumes:
    - /etc/localtime:/etc/localtime:ro
    - './phpConfig/config.inc.php:/etc/phpmyadmin/config.inc.php'
    environment:
    - PMA_HOST=db
    - PMA_PORT=3306
    ports:
    - 8086:80
networkpotato commented 4 years ago

I'm not, and have never used docker compose so I don't know how you add it there, but try adding

--link mariadb:db

And remove PMA_HOST and PMA_PORT

This is my full run command that works:

sudo docker run --name phpmyadmin -d --link mariadb:db -p 84:80 -v /volume1/docker/phpmyadmin/config.inc.php:/etc/phpmyadmin/config.inc.php phpmyadmin/phpmyadmin

AbDhops commented 4 years ago

I imagine your config.inc.php is the one from comment ? Unfortunately error still continues...

networkpotato commented 4 years ago

I imagine your config.inc.php is the one from comment ? Unfortunately error still continues...

Yep.

The only thing I can think of that you can try is adding back in the PMA_HOST and PMA_PORT and try using the local Docker IP of the database container.

If that doesn't work either, I suggest you open your own issue and reference this issue so that people with more experience can help you. I think your problem isn't the same as mine was seeing as adding the config file didn't work for you :/

AbDhops commented 4 years ago

So RTFM... I learned it in hard way... I overlooked the clear warning on MariaDB docker page..

No connections until MySQL init completes

If there is no database initialized when the container starts, then a default database will be created. While this is the expected behavior, this means that it will not accept incoming connections until such initialization completes. This may cause issues when using automation tools, such as docker-compose, which start several containers simultaneously.

For fresh instant, it took almost 11 minutes, until Phpmyadmin (or for that matter any one) to eastablish connection with database.

Gofoodi commented 1 year ago

Combination of both topics solved the problem for me. THANK YOU. Searched for the error for several hours now...

Looks like a duplicate of #264

I tried adding --default-authentication-plugin=mysql_native_password to my command, but nothing happened, beside a line in the log that says it's a feature of mysql that hasn't been implemented yet.

Other than that, I can't see any other differences between my command and the one that resolved the problem in #264 ?

SOLVED!

After a couple more hours of Googling I came across this thread.

What I had to do was to create a file called config.inc.php and map it up with the container:

-v /volume1/docker/phpmyadmin/config.inc.php:/etc/phpmyadmin/config.inc.php

And add the following content to the file

And it just worked like that!