Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection error mariadb + wordpress with docker

I have a docker-compose where I pick up two containers, one with mariadb and one with wordpress.

The problem

I receive a connection failure, apparently the user loses and cannot perform authentication.

wp-mysql | 2019-08-09 13:21:16 18 [Warning] Aborted connection 18 to db: > 'unconnected' user: 'unauthenticated' host: '172.31.0.3' (This connection > closed normally without authentication)

Situation

When I go to http: // localhost: 8010 the wordpress service is available, but with an error connecting to the database.

The docker-compose.yml ...

version: '3'

services:
  db:
    container_name: wp-mysql
    image: mariadb
    volumes:
       - $PWD/data:/var/lib/mysql
    environment:
       MYSQL_ROOT_PASSWORD: 12345678
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
    ports:
       - "3307:3306"
    networks:
       - my_net
    restart: on-failure

  wp:
    depends_on:
       - db
    container_name: wp-web
    volumes:
       - "$PWD/html:/var/www/html"
    image: wordpress
    ports:
       - "8010:80"
    environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
    networks:
       - my_net

networks:
  my_net:

Error:

wp-mysql | 2019-08-09 13:21:16 18 [Warning] Aborted connection 18 to db: > 'unconnected' user: 'unauthenticated' host: '172.31.0.3' (This connection > closed normally without authentication)

Where is the configuration error?

Why can't the wordpress container not use the user created in the mariadb container environment?

like image 686
Eduard Pinuaga Avatar asked Aug 09 '19 13:08

Eduard Pinuaga


People also ask

How do I connect my MariaDB Docker container?

Execute the following to connect to MariaDB using the command-line client: > docker exec -it mdb mariadb --user root -pPassword123! And that's it! That's all you need to connect to and start using (querying) MariaDB.

Is WordPress compatible with MariaDB?

WordPress started with MySQL as its backend, but since MariaDB was developed as a drop-in replacement of MySQL, MySQL can be replaced with MariaDB as the backend for WordPress. This takes advantage of MariaDB's better performance in addition to new features like new and improved database engines.

How do I connect to a MySQL Docker container?

Here are the steps you can follow to install the Dockerhub MySQL Container: Step 1: Pull the Docker Image for MySQL. Step 2: Deploy and Start the MySQL Container. Step 3: Connect with the Docker MySQL Container.

Is Docker good for WordPress?

For that reason, Docker is highly useful for WordPress developers. A WordPress test environment usually eats up a lot of system resources, but Docker helps them make a minimal environment without wasting server space and memory.


1 Answers

Finally solve it.

After going around and helped by the user @JackNavaRow the solution came out.

It was as simple as rebooting the system and deleting the volumes.

Pick up the containers and everything worked ok.

I leave it here in case anyone encounters this problem, that does not give more turns.

like image 65
Eduard Pinuaga Avatar answered Sep 25 '22 09:09

Eduard Pinuaga