nezhar / wordpress-docker-compose

Easy Wordpress development with Docker and Docker Compose
MIT License
1.84k stars 1.31k forks source link

MySQL Connection Error: (2002) Connection refused #54

Open kostberg opened 4 years ago

kostberg commented 4 years ago

I think the problem here is that apache can't determine its domain name:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.4. Set the 'ServerName' directive globally to suppress this

This is the code that I'm getting thrown in the terminal:

G:\Projects\Docker projects\wordpress\wordpress-docker-compose>docker-compose up Creating network "wordpress-docker-compose_default" with the default driver Creating volume "wordpress-docker-compose_db_data" with default driver Creating wordpress-docker-compose_db_1 ... done Creating wordpress-docker-compose_wp_1 ... done Creating wordpress-docker-compose_pma_1 ... done Creating wordpress-docker-compose_wpcli_1 ... done Attaching to wordpress-docker-compose_db_1, wordpress-docker-compose_pma_1, wordpress-docker-compose_wp_1, wordpress-docker-compose_wpcli_1 db_1 | 2020-04-10 20:27:07+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. db_1 | 2020-04-10 20:27:08+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2020-04-10 20:27:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. db_1 | 2020-04-10 20:27:09+00:00 [Note] [Entrypoint]: Initializing database files db_1 | 2020-04-10T20:27:09.186328Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. wp_1 | [10-Apr-2020 20:27:12 UTC] PHP Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22 wpcli_1 | Error: Error establishing a database connection. wordpress-docker-compose_wpcli_1 exited with code 1 pma_1 | phpMyAdmin not found in /var/www/html - copying now... pma_1 | Complete! phpMyAdmin has been successfully copied to /var/www/html pma_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message pma_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message pma_1 | [Fri Apr 10 20:27:15.565929 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.4 configured -- resuming normal operations wp_1 | wp_1 | MySQL Connection Error: (2002) Connection refused db_1 | 2020-04-10T20:27:09.186491Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 40 wp_1 | wp_1 | MySQL Connection Error: (2002) Connection refused db_1 | 2020-04-10T20:27:16.340599Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. db_1 | 2020-04-10 20:27:21+00:00 [Note] [Entrypoint]: Database files initialized wp_1 | wp_1 | MySQL Connection Error: (2002) Connection refused db_1 | 2020-04-10 20:27:21+00:00 [Note] [Entrypoint]: Starting temporary server db_1 | 2020-04-10T20:27:22.287388Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. db_1 | 2020-04-10T20:27:22.288576Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 90 db_1 | 2020-04-10T20:27:23.456291Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. db_1 | 2020-04-10T20:27:23.464007Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2020-04-10T20:27:23.506800Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL. db_1 | 2020-04-10 20:27:23+00:00 [Note] [Entrypoint]: Temporary server started. wp_1 | wp_1 | MySQL Connection Error: (2002) Connection refused db_1 | 2020-04-10T20:27:23.633893Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' db_1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it. wp_1 | wp_1 | MySQL Connection Error: (2002) Connection refused wp_1 | wp_1 | MySQL Connection Error: (2002) Connection refused db_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it. db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it. db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it. db_1 | 2020-04-10 20:27:33+00:00 [Note] [Entrypoint]: Creating database wordpress db_1 | db_1 | 2020-04-10 20:27:33+00:00 [Note] [Entrypoint]: Stopping temporary server wp_1 | wp_1 | MySQL Connection Error: (2002) Connection refused db_1 | 2020-04-10T20:27:33.544319Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.19). db_1 | 2020-04-10T20:27:34.702236Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL. db_1 | 2020-04-10 20:27:35+00:00 [Note] [Entrypoint]: Temporary server stopped db_1 | db_1 | 2020-04-10 20:27:35+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up. db_1 | db_1 | 2020-04-10T20:27:35.934708Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. db_1 | 2020-04-10T20:27:35.934942Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 1 db_1 | 2020-04-10T20:27:36.735152Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. db_1 | 2020-04-10T20:27:36.740689Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2020-04-10T20:27:36.797819Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL. wp_1 | wp_1 | MySQL Connection Error: (2002) Connection refused wp_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.4. Set the 'ServerName' directive globally to suppress this message wp_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.4. Set the 'ServerName' directive globally to suppress this message wp_1 | [Fri Apr 10 20:27:37.451003 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.3.16 configured -- resuming normal operations

flip111 commented 4 years ago

I think the problem here is that apache can't determine its domain name:

My docker instance works well and i see this message too. Also this message (by apache) comes after "Connection refused" (by php). Doesn't seem directly related.

Instead use sudo netstat to find used ports on your system see if some service is already using the ports the docker containers want to be using. I noticed that sometimes docker leaves ports blocked even if they are shut down, restart your pc in that case.

nezhar commented 4 years ago

Sometimes the setup of the db service may take some more time to setup (mostly when using an existing dump). I would rather suggest to stop and restart the containers after the database is done importing (it will log that is ready for connections once done).

chucklin72 commented 3 years ago

I have been having an issue with databases as well. trying wpcli fails because it says file was not readable. Uploading using phpmyadmin fails too. I think the problem is that the sql file is bigger than 2MB. Although php.ini in the container set to 64MB upload, phpmyadmin shows that the max upload size is 2MB.

For my case I was able to zip the database before uploading it with phpmyadmin. that worked ok. Then i used wpcli to do a search-replace

I have yet to figure out why wpcli db import fails on my 2.5MB file.