i have a little problem with mysql server. i created my docker-compose.yml, but when i want to access to phpMyAdmin [localhost:8080], an error message appeared sais that: "phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. Please check the values of host, username and password in the configuration and make sure they match the information provided by the MySQL server administrator".
Here is my docker-compose file and thanks for helping me
version: '2'
services:
apache:
image: rafaelcgstz/magento2
# build: .
ports:
- 80:80
- 9001:9000
# - "35729:35729" # live reload
volumes:
- ./src:/var/www/html
- ~/.composer:/var/www/.composer
- ~/.npm:/var/www/.npm
# - ~/.nvm:/var/www/.nvm
environment:
XDEBUG_CONFIG: "remote_host=localhost"
PHP_IDE_CONFIG: "serverName=Docker"
depends_on:
- db
links:
- db
networks:
- magento-network
db:
image: mariadb
ports:
- 3300:3306
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=magento
- MYSQL_USER=magento
- MYSQL_PASSWORD=magento
volumes:
- dbdata:/var/lib/mysql
networks:
- magento-network
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
- PMA_HOST=db
- PMA_USER=root
- PMA_PASSWORD=root
- MYSQL_ROOT_PASSWORD=root
ports:
- 8080:80
networks:
- magento-network
redis:
image: redis
ports:
- 6379
networks:
- magento-network
redis-session:
image: redis
ports:
- 6379
networks:
- magento-network
mailhog:
image: mailhog/mailhog
ports:
- 1025:1025
- 8025:8025
networks:
- magento-network
networks:
magento-network:
driver: bridge
volumes:
dbdata:
driver: local
asked Sep 7, 2019 at 13:25
Seems like you have a typo in mariadb
service definition:
ports:
- 3300:3306
You configured port mapping so that container is reachable at 3300
but you did not pass this information to PHPMyadmin. As a result connection attempt just times out.
Side note: you do not need to expose port for database at all - other containers will communicate with it using Docker's virtual network and for local access you can use docker container -it exec mysql...
or docker-compose exec db mysql...
answered Sep 7, 2019 at 14:10
Tomasz KapłońskiTomasz Kapłoński
1,2502 gold badges20 silver badges45 bronze badges
while it appears there is a typo for the port with this post I want to point out that it's important to make sure that your user has access 'TO' and 'FROM' the appropriate IP.
This is an [wide open -adjust as needed] example for updating the access domain when running adminer / phpadmin via docker:
GRANT ALL ON . TO 'admin'@'172.18.0.0/255.255.255.0' IDENTIFIED BY 'password' WITH GRANT OPTION;
p.s. I'm adding this answer here because I also landed on this page with the same error.
answered Nov 21, 2019 at 0:34
I solved my problem with this command:
docker-compose destroy
sudo rm -rf db/
docker-compose up -d
docker-compose web
composer install
symfony d:m:m --no-interaction
symfony d:f:l --no-interaction
answered Aug 22 at 17:50
Hi there, I have been trying to move from a Digital Ocean managed db to a in servier Docker one, but I have been dealing with this error since yesterday. I have exported the database using phpMyAdmin successfully, and when I try to import it I get the error
Error
Static analysis:
1 errors were found during analysis.
Missing expression. [near "ON" at position 25]
SQL query: Copy Edit Edit
SET FOREIGN_KEY_CHECKS = ON;
MySQL said: Documentation
#2006 - MySQL server has gone away
Here it the image of the error: //s3.marroquin.dev/mysql/error.jpg
I am trying to restore a 11.9 mb wordpress database and getting the error, but I was successfull to restore another wordpress database of 4.70 mb
Here is the docker-compose.yml
file where I put the configuration without a cnf
file for the mySQL image [where I think that the error is]: command: --max-allowed-packet=500M --log-error-verbosity=3 --connect-timeout=100 --thread-cache-size=100 --innodb-io-capacity=500
version: "3.8"
networks:
default:
name: nginx-proxy
internal:
internal: true
volumes:
certs:
dhpar:
htmls:
vhost:
mysql:
services:
nginx:
container_name: proxy_nginx
image: nginxproxy/nginx-proxy
ports:
- 80:80
- 443:443
restart: unless-stopped
volumes:
- certs:/etc/nginx/certs
- dhpar:/etc/nginx/dhparam
- vhost:/etc/nginx/vhost.d
- htmls:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
letsencrypt:
container_name: proxy_acme
depends_on:
- nginx
image: nginxproxy/acme-companion
environment:
DEFAULT_EMAIL:
NGINX_PROXY_CONTAINER: proxy_nginx
restart: unless-stopped
volumes:
- certs:/etc/nginx/certs
- dhpar:/etc/nginx/dhparam
- vhost:/etc/nginx/vhost.d
- htmls:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
mysql:
command: --max-allowed-packet=500M --log-error-verbosity=3 --connect-timeout=100 --thread-cache-size=100 --innodb-io-capacity=500
container_name: db_mysql
depends_on:
- letsencrypt
environment:
MYSQL_USER: commonadmin
MYSQL_DATABASE: defaultdb
MYSQL_PASSWORD: myPass374324
MYSQL_ROOT_PASSWORD: therootPass23532
image: mysql:8
networks:
- internal
ports:
- 3306:3306
restart: unless-stopped
volumes:
- /root/wordpress/mysql:/var/lib/mysql
admin:
container_name: db_admin
depends_on:
- mysql
environment:
PMA_ARBITRARY: 1
MEMORY_LIMIT: 1G
UPLOAD_LIMIT: 100M
VIRTUAL_HOST: db.example.com
LETSENCRYPT_HOST: db.example.com
image: phpmyadmin/phpmyadmin
networks:
- default
- internal
ports:
- 9000
restart: unless-stopped
Although I don't think the size of the database is the problem because I tried restoring each table one by one and wp_postmeta.sql
[5.82 mb] copied just fine, but wp_posts.sql
[1.96 mb] gave me
the same error
Here is the log of docker run -it --rm mysql:8 --verbose --help with all arguments I can use