Both WordPress and MySQL in pod has issue

Hello,

I am trying to create Both WordPress and MySQL in pod, please see my yaml.
https://paste.ubuntu.com/p/BJbfnrY7X7/

The error is WordPress can’t connect to MySQL through 127.0.0.1, I don’t know why Host ‘127.0.0.1’ is not allowed to connect to this MySQL server

[root@sealos01 ingress]# kubectl logs --tail 10 wordpress-app-86d9b59576-flcjv wordpress

Warning: mysqli::mysqli(): (HY000/2002): Connection refused in - on line 19

Warning: mysqli::mysqli(): (HY000/1130): Host ‘127.0.0.1’ is not allowed to connect to this MySQL server in - on line 19

MySQL Connection Error: (1130) Host ‘127.0.0.1’ is not allowed to connect to this MySQL server

Warning: mysqli::mysqli(): (HY000/1130): Host ‘127.0.0.1’ is not allowed to connect to this MySQL server in - on line 19

MySQL Connection Error: (1130) Host ‘127.0.0.1’ is not allowed to connect to this MySQL server

Warning

Thanks

Hello,

I tried without volume working

https://paste.ubuntu.com/p/J9nDCM9NZY/

Hello,

Can someone help?

Thanks

No one have encountered this issue ???

Hello, leiw
What are you writing in DB_HOST?

Hello,

It is default DB_HOST

Thanks

I tested this with PVs on both Wordpress and MySQL and did not see any issues.

The error you are receiving is a MySQL permissions issue. It’s not related to Kubernetes.
If it is working without PVs then that show the problem is with the MySQL configuration files stored on the PV.
You need to connect to the MySQL database and make sure the wordpress user has the correct privileges to connect using 127.0.0.1.

Kind regards,
Stephen

Better practice is separation front and db to two different deployments or even use StatefulSet for db.
Then use service for db ( WORDPRESS_DB_HOST=mydbserivce).
Also mysql:5.7 relatively old and may not maintained so well. Use stable mariadb:10