Wordpress issues

Hi,

I am a newbie to docker and seeing DB connectivity issues in my wordpress logs.

[root@localhost wordpress]# docker logs wordpress --details [09-Aug-2024 16:02:31 UTC] PHP Warning:

mysqli::__construct(): MySQL server has gone away in Standard input code on line 22 [09-Aug-2024 16:02:31 UTC] PHP Warning: mysqli::__construct(): Error while reading greeting packet. PID=87 in Standard input code on line 22 [89-Aug-2824 16:02:31 UTC] PHP Warning: mysqli::__construct(): (HY000/2006): MySQL server has gone away in Standard input code on line 22

MySQL Connection Error: (2006) MySQL server has gone away

MySQL “CREATE DATABASE” Error: Access denied for user ‘user01’@‘%’ to database ‘db’

WARNING: unable to establish a database connection to ‘********:3306’ continuing anyways (which might have unexpected results)

[09-Aug-2024 16:02:34] NOTICE: fpm is running, pid 1 [89-Aug-2824 16:02:34] NOTICE: ready to handle connections

All webserver, db and wordpress containers are in start state. However, seeing the above errors only in wordpress logs.

here is my docker-compose ( db and wordpress containers only ) and I masked IP with *******

services:

db:

image: mariadb

container\_name: db

restart: unless-stopped

ports:

	- "3306:3306"

env\_file: .env

environment:

	MARIADB\_ROOT\_PASSWORD: $DB\_PASSWORD

	MARIADB\_DATABASE: db

	MARIADB\_USER: $DB\_USER

	MARIADB\_PASSWORD: "password@1"

	MARIADB\_HOST: "\*\*\*\*\*\*\*\*\*:3306"

	# MARIADB\_PORT: 3306

volumes:

	- ./dbdata:/var/lib/mysql

	#command: '--default-authentication-plugin=mysql\_native\_password'

networks:

	- wp-network

wordpress:

depends\_on:

	- db

image: wordpress:5.1.1-fpm-alpine

container\_name: wordpress

restart: unless-stopped

#expose:

	#- '9000'

#ports:

	#- "9000:9000"

env\_file: .env

environment:

	WORDPRESS\_DEBUG: 1

	WORDPRESS\_DB\_NAME: db

	WORDPRESS\_DB\_HOST: "\*\*\*\*\*\*\*:3306"

	# WORDPRESS\_DB\_PORT: 3306

	WORDPRESS\_DB\_USER: $DB\_USER

	WORDPRESS\_DB\_PASSWORD: "password01"

volumes:

	-wordpress: /var/www/html

networks:

	- wp-network

Port 3306 is open. I confirmed using a nmap.

userid, password, host, port all work well, I confirmed it by running a mysql and connecting to it.

I also ran a config and able to see that all values are loading fine. I am running docker compose as root user.

What is the % sign after user01@. Shouldn’t that be an IP ? Please help. I am loosing my mind over this.

You config looks weird, spacing partial broken and it’s full of \s.

Use 3 backticks before and after config/code to make it more readable.