Docker MYSQL '[2002] Connection refused'
The '[2002] Connection refused' means you can reach the database server, but you don't have right access for the user (in your case admin). By default mariadb have a root user with the password given by MYSQL_ROOT_PASSWORD and this user can connect from any server (%).
If you want use an over login to your databases, you have to create it in the databases server with the right granting on databases from chosen locations.
The problem here is that you have named your database server as 'mysql' (service name in the docker-compose file). But by default phpmyadmin tries to connect to a database server named 'db'. Adding PMA_HOST: mysql
under the environment section of the phpmyadmin service will resolve this problem.
I think that MYSQL_USERNAME and PMA_ARBITRARY are useless if you work with default configuration (connection with root to your databases server)
I had this challenge because I am running 3 different containers with different IP Addresses
db - 172.18.0.3 - container for MYSQLapp - 172.18.0.2 - container for Laravel app
so I fixed it by editing my Laravel .env file
DB_CONNECTION=mysqlDB_HOST=172.18.0.3DB_PORT=3306DB_DATABASE=database_nameDB_USERNAME=username...
To get your containers Ip addresses. From your docker host
docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
UPDATED:For latest docker versions and based on the services name, "mysql", in your docker-compose.yml
mysql: image: mariadb ports: - 3306:3306
You can try this:
DB_CONNECTION=mysqlDB_HOST=mysqlDB_PORT=3306DB_DATABASE=database_nameDB_USERNAME=username
DB_HOST is the name of MySQL service name defined in docker-compose.yml