evertramos / docker-wordpress

Wordpress Docker container using SSL Certificates with LetsEncrypt
https://evertramos.github.io/docker-wordpress/
MIT License
484 stars 156 forks source link

"Error establishing a database connection" while deploying the container, possible problem with passwords that have symbols #42

Closed mcastillof closed 4 years ago

mcastillof commented 4 years ago

If you see the following message in a browser while you try to access your Wordpress instance:

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at coders-cl-db:3306. This could mean your host’s database server is down.

    Are you sure you have the correct username and password?
    Are you sure you have typed the correct hostname?
    Are you sure the database server is running?

If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

It may be related to a password problem in MYSQL_ROOT_PASSWORD variable ((MYSQL_PASSWORD could suffer a similar problem but I haven't tested it).

I'm using your docker-compose.yml + .env.sample files to deploy a Wordpress environment. After starting the containers for the first time (and waiting for the certs generation), if I surf to the server with a browser, I see the message above.

Steps done:

git clone https://github.com/evertramos/docker-wordpress-letsencrypt.git cp .env.sample .env nano .env #edit parameters, I'm using MariaDB 10.4 and Wordpress 5.4 tags. docker-compose up -d

The following is a list of passwords that I have tested in terms of container working and showing the wizard. Passwords not working, are the ones that shows the error message shown above. I still don't know if all of the working passwords shown in this list wil be exactly the same in the DB, because they may be truncated.

MYSQL_ROOT_PASSWORD=abc123             Works
MYSQL_ROOT_PASSWORD=abc"123            Works
MYSQL_ROOT_PASSWORD=abc"\123           Doesn't work. Notice that i'm not escaping the quote
MYSQL_ROOT_PASSWORD=abc"\\123          Works
MYSQL_ROOT_PASSWORD=abc"\\#123        Doesn't work
MYSQL_ROOT_PASSWORD="abc"\\#123"      Works, but, will the password be truncated to "abc"?
MYSQL_ROOT_PASSWORD="abc"\\#`´'%&$¿?¡!@¬|-.,_:;{}[]+*¨()/'<>€·~½°123"      Doesn't work
MYSQL_ROOT_PASSWORD='abc"\\#123'       Doesn't work

I still don't know the correct way to set a password with symbols in a safe way. I expected that single quotes worked here, but it doesn't.

Docker-compose logs when the a bad password is being used:

Attaching to example-io-wordpress, docker-wordpress-letsencrypt_wpcli_1, example-io-db
example-io-db          | 2020-04-09 18:46:24+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started.
example-io-db          | 2020-04-09 18:46:24+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
example-io-db          | 2020-04-09 18:46:24+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started.
example-io-db          | 2020-04-09 18:46:25+00:00 [Note] [Entrypoint]: Initializing database files
example-io-db          | 
example-io-db          | 
example-io-db          | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
example-io-db          | To do so, start the server, then issue the following commands:
example-io-db          | 
example-io-db          | '/usr/bin/mysqladmin' -u root password 'new-password'
example-io-db          | '/usr/bin/mysqladmin' -u root -h  password 'new-password'
example-io-db          | 
example-io-db          | Alternatively you can run:
example-io-db          | '/usr/bin/mysql_secure_installation'
example-io-db          | 
example-io-db          | which will also give you the option of removing the test
example-io-db          | databases and anonymous user created by default.  This is
example-io-db          | strongly recommended for production servers.
example-io-db          | 
example-io-db          | See the MariaDB Knowledgebase at http://mariadb.com/kb or the
example-io-db          | MySQL manual for more instructions.
example-io-db          | 
example-io-db          | Please report any problems at http://mariadb.org/jira
example-io-db          | 
example-io-db          | The latest information about MariaDB is available at http://mariadb.org/.
example-io-db          | You can find additional information about the MySQL part at:
example-io-db          | http://dev.mysql.com
example-io-db          | Consider joining MariaDB's strong and vibrant community:
example-io-db          | https://mariadb.org/get-involved/
example-io-db          | 
example-io-db          | 2020-04-09 18:46:27+00:00 [Note] [Entrypoint]: Database files initialized
example-io-db          | 2020-04-09 18:46:27+00:00 [Note] [Entrypoint]: Starting temporary server
example-io-db          | 2020-04-09 18:46:27+00:00 [Note] [Entrypoint]: Waiting for server startup
example-io-db          | 2020-04-09 18:46:27 0 [Note] mysqld (mysqld 10.4.12-MariaDB-1:10.4.12+maria~bionic) starting as process 124 ...
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Using Linux native AIO
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Uses event mutexes
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Number of pools: 1
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Using SSE2 crc32 instructions
example-io-db          | 2020-04-09 18:46:27 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Completed initialization of buffer pool
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Creating shared tablespace for temporary tables
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
example-io-db          | 2020-04-09 18:46:27 0 [Note] InnoDB: Waiting for purge to start
example-io-db          | 2020-04-09 18:46:28 0 [Note] InnoDB: 10.4.12 started; log sequence number 60972; transaction id 21
example-io-db          | 2020-04-09 18:46:28 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
example-io-db          | 2020-04-09 18:46:28 0 [Note] Plugin 'FEEDBACK' is disabled.
example-io-db          | 2020-04-09 18:46:28 0 [Warning] 'user' entry 'root@5d56367ea7db' ignored in --skip-name-resolve mode.
example-io-db          | 2020-04-09 18:46:28 0 [Warning] 'user' entry '@5d56367ea7db' ignored in --skip-name-resolve mode.
example-io-db          | 2020-04-09 18:46:28 0 [Warning] 'proxies_priv' entry '@% root@5d56367ea7db' ignored in --skip-name-resolve mode.
example-io-db          | 2020-04-09 18:46:28 0 [Note] InnoDB: Buffer pool(s) load completed at 200409 18:46:28
example-io-db          | 2020-04-09 18:46:28 0 [Note] Reading of all Master_info entries succeeded
example-io-db          | 2020-04-09 18:46:28 0 [Note] Added new Master_info '' to hash table
example-io-db          | 2020-04-09 18:46:28 0 [Note] mysqld: ready for connections.
example-io-db          | Version: '10.4.12-MariaDB-1:10.4.12+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  mariadb.org binary distribution
example-io-db          | 2020-04-09 18:46:28+00:00 [Note] [Entrypoint]: Temporary server started.
example-io-db          | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
example-io-db          | ERROR 1064 (42000) at line 6: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '%&$¿?¡!@¬|-.,_:' at line 1
example-io-db          | 2020-04-09 18:46:41+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started.
example-io-db          | 2020-04-09 18:46:42+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
example-io-db          | 2020-04-09 18:46:42+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started.
example-io-db          | 2020-04-09 18:46:42 0 [Note] mysqld (mysqld 10.4.12-MariaDB-1:10.4.12+maria~bionic) starting as process 1 ...
example-io-db          | 2020-04-09 18:46:43 0 [Note] mysqld: Aria engine: starting recovery
example-io-db          | recovered pages: 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% (0.2 seconds); tables to flush: 3 2 1 0
example-io-db          |  (0.0 seconds); 
example-io-db          | 2020-04-09 18:46:43 0 [Note] mysqld: Aria engine: recovery done
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Using Linux native AIO
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Uses event mutexes
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Number of pools: 1
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Using SSE2 crc32 instructions
example-io-db          | 2020-04-09 18:46:43 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Completed initialization of buffer pool
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=60972
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Creating shared tablespace for temporary tables
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Waiting for purge to start
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: 10.4.12 started; log sequence number 60981; transaction id 21
example-io-db          | 2020-04-09 18:46:43 0 [Note] Plugin 'FEEDBACK' is disabled.
example-io-db          | 2020-04-09 18:46:43 0 [Note] Server socket created on IP: '::'.
example-io-db          | 2020-04-09 18:46:43 0 [Warning] 'proxies_priv' entry '@% root@5d56367ea7db' ignored in --skip-name-resolve mode.
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
example-io-db          | 2020-04-09 18:46:43 0 [Note] Reading of all Master_info entries succeeded
example-io-db          | 2020-04-09 18:46:43 0 [Note] Added new Master_info '' to hash table
example-io-db          | 2020-04-09 18:46:43 0 [Note] mysqld: ready for connections.
example-io-db          | Version: '10.4.12-MariaDB-1:10.4.12+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
example-io-db          | 2020-04-09 18:46:43 0 [Note] InnoDB: Buffer pool(s) load completed at 200409 18:46:43
example-io-db          | 2020-04-09 18:46:44 8 [Warning] Aborted connection 8 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.19' (This connection closed normally without authentication)
example-io-db          | 2020-04-09 18:46:47 9 [Warning] Aborted connection 9 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.19' (This connection closed normally without authentication)
example-io-db          | 2020-04-09 18:46:50 10 [Warning] Aborted connection 10 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.19' (This connection closed normally without authentication)
example-io-db          | 2020-04-09 18:46:53 11 [Warning] Aborted connection 11 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.19' (This connection closed normally without authentication)
example-io-db          | 2020-04-09 18:48:33 12 [Warning] Aborted connection 12 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.19' (This connection closed normally without authentication)
example-io-db          | 2020-04-09 18:53:41 13 [Warning] Aborted connection 13 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.19' (This connection closed normally without authentication)
example-io-wordpress   | WordPress not found in /var/www/html - copying now...
example-io-wordpress   | WARNING: /var/www/html is not empty! (copying anyhow)
example-io-wordpress   | Complete! WordPress has been successfully copied to /var/www/html
example-io-wordpress   | [09-Apr-2020 18:46:26 UTC] PHP Warning:  mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2002) Connection refused
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2002) Connection refused
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2002) Connection refused
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2002) Connection refused
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2002) Connection refused
example-io-wordpress   | [09-Apr-2020 18:46:41 UTC] PHP Warning:  mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:41 UTC] PHP Warning:  mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in Standard input code on line 22
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known
example-io-wordpress   | [09-Apr-2020 18:46:44 UTC] PHP Warning:  Packets out of order. Expected 0 received 1. Packet size=70 in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:44 UTC] PHP Warning:  mysqli::__construct(): MySQL server has gone away in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:44 UTC] PHP Warning:  mysqli::__construct(): Error while reading greeting packet. PID=198 in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:44 UTC] PHP Warning:  mysqli::__construct(): (HY000/2006): MySQL server has gone away in Standard input code on line 22
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2006) MySQL server has gone away
example-io-wordpress   | [09-Apr-2020 18:46:47 UTC] PHP Warning:  Packets out of order. Expected 0 received 1. Packet size=70 in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:47 UTC] PHP Warning:  mysqli::__construct(): MySQL server has gone away in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:47 UTC] PHP Warning:  mysqli::__construct(): Error while reading greeting packet. PID=198 in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:47 UTC] PHP Warning:  mysqli::__construct(): (HY000/2006): MySQL server has gone away in Standard input code on line 22
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2006) MySQL server has gone away
example-io-wordpress   | [09-Apr-2020 18:46:50 UTC] PHP Warning:  Packets out of order. Expected 0 received 1. Packet size=70 in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:50 UTC] PHP Warning:  mysqli::__construct(): MySQL server has gone away in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:50 UTC] PHP Warning:  mysqli::__construct(): Error while reading greeting packet. PID=198 in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:50 UTC] PHP Warning:  mysqli::__construct(): (HY000/2006): MySQL server has gone away in Standard input code on line 22
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2006) MySQL server has gone away
example-io-wordpress   | [09-Apr-2020 18:46:53 UTC] PHP Warning:  Packets out of order. Expected 0 received 1. Packet size=70 in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:53 UTC] PHP Warning:  mysqli::__construct(): MySQL server has gone away in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:53 UTC] PHP Warning:  mysqli::__construct(): Error while reading greeting packet. PID=198 in Standard input code on line 22
example-io-wordpress   | [09-Apr-2020 18:46:53 UTC] PHP Warning:  mysqli::__construct(): (HY000/2006): MySQL server has gone away in Standard input code on line 22
example-io-wordpress   | 
example-io-wordpress   | MySQL Connection Error: (2006) MySQL server has gone away
example-io-wordpress   | 
example-io-wordpress   | WARNING: unable to establish a database connection to 'example-io-db:3306'
example-io-wordpress   |   continuing anyways (which might have unexpected results)
example-io-wordpress   | 
example-io-wordpress   | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.19. Set the 'ServerName' directive globally to suppress this message
example-io-wordpress   | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.19. Set the 'ServerName' directive globally to suppress this message
example-io-wordpress   | [Thu Apr 09 18:46:53.557121 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.3.16 configured -- resuming normal operations
example-io-wordpress   | [Thu Apr 09 18:46:53.557385 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
example-io-wordpress   | 190.46.16.48 - - [09/Apr/2020:18:48:33 +0000] "GET / HTTP/1.1" 500 2953 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0"
example-io-wordpress   | 190.46.16.48 - - [09/Apr/2020:18:53:41 +0000] "GET / HTTP/1.1" 500 2953 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0"
wpcli_1               | Error: Error establishing a database connection.
evertramos commented 4 years ago

Closing this issue... you can set password with double quotes....

MYSQL_ROOT_PASSWORD="!@$makeyouwish123"