1

I'm trying to implement this pre-cooked package of NGINX, PHP-FPM, MySQL, E-L-K.

Everything is working fine but the connection with the database. It throws a ConnectionException.

I'm not really sure if the program should try to access 172.18.0.4 instead of 172.18.0.3, and where does this configuration comes from.

The IPs of my containers are:

/dockersymfony_elk_1 - 172.18.0.2

/dockersymfony_nginx_1 - 172.18.0.5

/dockersymfony_php_1 - 172.18.0.3

/dockersymfony_db_1 - 172.18.0.4

The error:

[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'root'@'172.18.0.3' (using password: YES)

What could be happenning? Is there a way to check a mysql connection manually?

CarlosAS
  • 435
  • 1
  • 5
  • 9

2 Answers2

3

Since the response is Access denied for user so the port and the ip address is correct.

I guess the only issue as @James said will be in the permission, you have to allow root access to mysql from elk and php containers, you can do it in easy way but it's not secure:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
  • %: mean match all

or you can specify who has the access per domain name or ip:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.18.0.2' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.18.0.3' IDENTIFIED BY 'password';

PS: don't forget to change the password to match you root password

Wissam Roujoulah
  • 422
  • 1
  • 3
  • 8
1

First, confirm that the container is actually listening for connections and has properly bound to the interface. If not, you probably need to fix the bind-address= and/or port= directives in your my.cnf.

Otherwise, you probably have an issue with your GRANTs. Check that the IP/subnet is correctly authorized in the mysql.user table with the command

select user,host from mysql.user

If the host field is incorrect, you will need to fix it using a UPDATE

James Shewey
  • 3,752
  • 1
  • 17
  • 38