Docker Community Forums

Share and learn in the Docker community.

Wordpress MySQL Connection Error

Hello, i’m trying to install wordpress in docker and i have a problem when i execute:
docker run --name some-wordpress -p 8081:80 -d wordpress** ** docker-compose -f stack.yml up


OS: Windows 7 (I tried in Fedora 30 too)
Docker Version: 1.20.1
Docker-compose version 1.20.1


my file docker-compose.yml is:

version: ‘3.1’

services:

wordpress:
links:

  • db
    image: wordpress
    restart: always
    ports:
  • 8081
    environment:
    WORDPRESS_DB_HOST: db
    WORDPRESS_DB_USER: exampleuser
    WORDPRESS_DB_PASSWORD: examplepass
    WORDPRESS_DB_NAME: exampledb
    volumes:
  • wordpress:/var/www/html

db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: ‘1’
volumes:

  • db:/var/lib/mysql

volumes:
wordpress:
db:


When i try:
$ docker-compose -f stack.yml up

I have this errors:


db_1 | Version: ‘5.7.30’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 MySQL Community Server (GPL)
wordpress_1 | [25-May-2020 05:25:46 UTC] PHP Warning: mysqli::__construct(): (HY000/1045): Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES) in Standard input code on line 22
db_1 | 2020-05-25T05:25:46.989625Z 2 [Note] Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
db_1 | 2020-05-25T05:25:49.994447Z 3 [Note] Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
db_1 | 2020-05-25T05:25:52.999923Z 4 [Note] Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
db_1 | 2020-05-25T05:25:56.005195Z 5 [Note] Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
db_1 | 2020-05-25T05:25:59.011116Z 6 [Note] Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
db_1 | 2020-05-25T05:26:02.014544Z 7 [Note] Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
db_1 | 2020-05-25T05:26:05.018978Z 8 [Note] Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
db_1 | 2020-05-25T05:26:08.031773Z 9 [Note] Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
db_1 | 2020-05-25T05:26:11.050647Z 10 [Note] Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | MySQL Connection Error: (1045) Access denied for user ‘exampleuser’@‘172.18.0.3’ (using password: YES)
wordpress_1 |
wordpress_1 | WARNING: unable to establish a database connection to ‘db’
wordpress_1 | continuing anyways (which might have unexpected results)
wordpress_1 |
wordpress_1 | AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.18.0.3. Set the ‘ServerName’ directive globally to suppress this message
wordpress_1 | AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 172.18.0.3. Set the ‘ServerName’ directive globally to suppress this message
wordpress_1 | [Mon May 25 05:26:14.414460 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.3.18 configured – resuming normal operations


I can see the wordpress setup configuration in “http://192.168.99.100:8081/”, i can choose the language, but when i send the information on the database, i have a “Error establishing a database connection”.

1 Like

This is probably a timing problem, the db may not yet have been created when Wordpress starts up. So for the first start, comment out the wordpress service, wait until the db is created (until the log gets silent), stop the container, remove the comments, start again.
Ping @parag7777.

The next time please format your compose file as code.

2 Likes

Hi

I got an answer for this problem details are as under as I have installed docker using Docker Toolbox

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v19.03.5

Now if I do

http://192.168.99.100:8000/

Now finally it is working. Hopefully it will help you too

2 Likes

Hello everyone :wave:
Have a nice day
Thank you!!

Hi, thanks for the answers. I’m new in the forum and i’m new in docker too.

I tried that, i commented out the workpress service:

$ docker-compose -f stack.yml up
Creating wordpress_db_1 ... done
Attaching to wordpress_db_1
db_1  | 2020-05-25 15:34:30+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.30-1debian10 started.
db_1  | 2020-05-25 15:34:30+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1  | 2020-05-25 15:34:30+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.30-1debian10 started.
db_1  | 2020-05-25T15:34:30.828863Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1  | 2020-05-25T15:34:30.830343Z 0 [Note] mysqld (mysqld 5.7.30) starting as process 1 ...
db_1  | 2020-05-25T15:34:30.833837Z 0 [Note] InnoDB: PUNCH HOLE support available
db_1  | 2020-05-25T15:34:30.834308Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1  | 2020-05-25T15:34:30.834513Z 0 [Note] InnoDB: Uses event mutexes
db_1  | 2020-05-25T15:34:30.834664Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
db_1  | 2020-05-25T15:34:30.834937Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1  | 2020-05-25T15:34:30.835274Z 0 [Note] InnoDB: Using Linux native AIO
db_1  | 2020-05-25T15:34:30.835999Z 0 [Note] InnoDB: Number of pools: 1
db_1  | 2020-05-25T15:34:30.836808Z 0 [Note] InnoDB: Using CPU crc32 instructions
db_1  | 2020-05-25T15:34:30.839984Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
db_1  | 2020-05-25T15:34:30.852072Z 0 [Note] InnoDB: Completed initialization of buffer pool
db_1  | 2020-05-25T15:34:30.855852Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db_1  | 2020-05-25T15:34:30.869013Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
db_1  | 2020-05-25T15:34:30.946299Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1  | 2020-05-25T15:34:30.946834Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1  | 2020-05-25T15:34:31.041046Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1  | 2020-05-25T15:34:31.046143Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
db_1  | 2020-05-25T15:34:31.047055Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
db_1  | 2020-05-25T15:34:31.050158Z 0 [Note] InnoDB: Waiting for purge to start
db_1  | 2020-05-25T15:34:31.105204Z 0 [Note] InnoDB: 5.7.30 started; log sequence number 12493563
db_1  | 2020-05-25T15:34:31.107646Z 0 [Note] Plugin 'FEDERATED' is disabled.
db_1  | 2020-05-25T15:34:31.114522Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db_1  | 2020-05-25T15:34:31.131628Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200525 15:34:31
db_1  | 2020-05-25T15:34:31.135016Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
db_1  | 2020-05-25T15:34:31.135491Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
db_1  | 2020-05-25T15:34:31.137637Z 0 [Warning] CA certificate ca.pem is self signed.
db_1  | 2020-05-25T15:34:31.138427Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
db_1  | 2020-05-25T15:34:31.140326Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
db_1  | 2020-05-25T15:34:31.140900Z 0 [Note] IPv6 is available.
db_1  | 2020-05-25T15:34:31.142000Z 0 [Note]   - '::' resolves to '::';
db_1  | 2020-05-25T15:34:31.142433Z 0 [Note] Server socket created on IP: '::'.
db_1  | 2020-05-25T15:34:31.241432Z 0 [Warning] 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-05-25T15:34:31.340400Z 0 [Note] Event Scheduler: Loaded 0 events
Gracefully stopping... (press Ctrl+C again to force)
Stopping wordpress_db_1 ... done

Then, i remove the comments, but it doesn’t work:


$ docker-compose -f stack.yml up
Starting wordpress_db_1 ... done
Creating wordpress_wordpress_1 ... done
Attaching to wordpress_db_1, wordpress_wordpress_1
db_1         | 2020-05-25 15:37:49+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.30-1debian10 started.
db_1         | 2020-05-25 15:37:49+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1         | 2020-05-25 15:37:49+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.30-1debian10 started.
db_1         | 2020-05-25T15:37:49.648385Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1         | 2020-05-25T15:37:49.649837Z 0 [Note] mysqld (mysqld 5.7.30) starting as process 1 ...
db_1         | 2020-05-25T15:37:49.653258Z 0 [Note] InnoDB: PUNCH HOLE support available
db_1         | 2020-05-25T15:37:49.653562Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1         | 2020-05-25T15:37:49.653951Z 0 [Note] InnoDB: Uses event mutexes
db_1         | 2020-05-25T15:37:49.654208Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
db_1         | 2020-05-25T15:37:49.654361Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1         | 2020-05-25T15:37:49.654570Z 0 [Note] InnoDB: Using Linux native AIO
db_1         | 2020-05-25T15:37:49.654994Z 0 [Note] InnoDB: Number of pools: 1
db_1         | 2020-05-25T15:37:49.655285Z 0 [Note] InnoDB: Using CPU crc32 instructions
db_1         | 2020-05-25T15:37:49.657342Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
db_1         | 2020-05-25T15:37:49.666634Z 0 [Note] InnoDB: Completed initialization of buffer pool
db_1         | 2020-05-25T15:37:49.669244Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db_1         | 2020-05-25T15:37:49.680792Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
db_1         | 2020-05-25T15:37:49.978765Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1         | 2020-05-25T15:37:49.979753Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1         | 2020-05-25T15:37:50.214994Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1         | 2020-05-25T15:37:50.218975Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
db_1         | 2020-05-25T15:37:50.220230Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
db_1         | 2020-05-25T15:37:50.222005Z 0 [Note] InnoDB: Waiting for purge to start
db_1         | 2020-05-25T15:37:50.276834Z 0 [Note] InnoDB: 5.7.30 started; log sequence number 12493591
db_1         | 2020-05-25T15:37:50.278908Z 0 [Note] Plugin 'FEDERATED' is disabled.
db_1         | 2020-05-25T15:37:50.287435Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db_1         | 2020-05-25T15:37:50.309217Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200525 15:37:50
db_1         | 2020-05-25T15:37:50.312965Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
db_1         | 2020-05-25T15:37:50.313535Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
db_1         | 2020-05-25T15:37:50.315375Z 0 [Warning] CA certificate ca.pem is self signed.
db_1         | 2020-05-25T15:37:50.315829Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
db_1         | 2020-05-25T15:37:50.317433Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
db_1         | 2020-05-25T15:37:50.318090Z 0 [Note] IPv6 is available.
db_1         | 2020-05-25T15:37:50.318489Z 0 [Note]   - '::' resolves to '::';
db_1         | 2020-05-25T15:37:50.319262Z 0 [Note] Server socket created on IP: '::'.
db_1         | 2020-05-25T15:37:50.693768Z 0 [Warning] 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-05-25T15:37:51.003771Z 0 [Note] Event Scheduler: Loaded 0 events
db_1         | 2020-05-25T15:37:51.004395Z 0 [Note] mysqld: ready for connections.
db_1         | Version: '5.7.30'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
wordpress_1  | [25-May-2020 15:37:53 UTC] PHP Warning:  mysqli::__construct(): (HY000/1045): Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES) in Standard input code on line 22
db_1         | 2020-05-25T15:37:53.303770Z 2 [Note] Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
db_1         | 2020-05-25T15:37:56.312835Z 3 [Note] Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
db_1         | 2020-05-25T15:37:59.320616Z 4 [Note] Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
db_1         | 2020-05-25T15:38:02.325927Z 5 [Note] Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
db_1         | 2020-05-25T15:38:05.330012Z 6 [Note] Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
db_1         | 2020-05-25T15:38:08.334228Z 7 [Note] Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
db_1         | 2020-05-25T15:38:11.338652Z 8 [Note] Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
db_1         | 2020-05-25T15:38:14.342441Z 9 [Note] Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
db_1         | 2020-05-25T15:38:17.348983Z 10 [Note] Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | MySQL Connection Error: (1045) Access denied for user 'exampleuser'@'172.18.0.3' (using password: YES)
wordpress_1  |
wordpress_1  | WARNING: unable to establish a database connection to 'db'
wordpress_1  |   continuing anyways (which might have unexpected results)
wordpress_1  |
wordpress_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.3. Set the 'ServerName' directive globally to suppress this message
wordpress_1  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.3. Set the 'ServerName' directive globally to suppress this message
wordpress_1  | [Mon May 25 15:38:20.525767 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.3.18 configured -- resuming normal operations

I have install docker using Docker Toolbox,

When i run

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v19.03.5

I do
http://192.168.99.100:8080/ to see the wordpress setup configuration, but i habe this error:

Is this question still open?