0

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?

  • 2
    The error msg appears to suggest a connection from 172.18.0.4 (or at least using the identity of that system's root user) not to it and it looks more of an access permission (or misconfigured user) issue. – Dan Cornilescu Aug 3 '17 at 16:25
  • Please add the docker command that was used to start the container – 030 Aug 3 '17 at 16:40
  • Yes. What are you connecting with? Code? Are you able to use the mysql command to connect using the appropriate switches? Are you specifying the database when you connect, or just connecting to mysql? I'll edit my answer below to address your specifics if you can provide this information. – James Shewey Aug 3 '17 at 17:35
2

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

  • 1
    IMHO Access denied for user doesn't necessarily mean the port and the ip address are correct - it could be the wrong server with the error message simply indicating the credentials intended for the right server aren't a match for the actual server. But I admit, it's not a very likely case :) – Dan Cornilescu Aug 9 '17 at 19:25
  • @DanCornilescu You are right, Actually what I meant to say that there are no firewall blocking the access to that ip and that port, and there is a service listening on that ip:port – Wissam Roujoulah Aug 10 '17 at 5:09
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.