Answers: <p>First, <a href="https://stackoverflow.com/questions/40350456/docker-any-way-to-list-open-sockets-inside-a-running-docker-container">confirm that the container is actually listening for connections and has properly bound to the interface</a>. If not, you probably need to fix the <code>bind-address=</code> and/or <code>port=</code> directives in your my.cnf.</p>
  
  <p>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</p>
  
  <pre><code>select user,host from mysql.user
  </code></pre>
  
  <p>If the host field is incorrect, you will need to fix it using a UPDATE</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-08-03T17:33:01.773Z
Answers: 2017-08-03T17:33:01.773Z
Answers: James Shewey
Answers: <p>Since the response is <code>Access denied for user</code> so the port and the ip address is correct.</p>
  
  <p>I guess the only issue as @James said  will be in the permission, you have to allow <code>root</code> access to mysql from elk and php containers, you can do it in easy way but it's not secure:</p>
  
  <pre><code>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
  </code></pre>
  
  <ul>
  <li><code>%</code>: mean match all</li>
  </ul>
  
  <p>or you can specify who has the access per domain name or ip:</p>
  
  <pre><code>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';
  </code></pre>
  
  <p>PS: don't forget to change the password to match you root password</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-08-09T19:25:05.373Z
Answers: 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 :)
Answers: Dan Cornilescu
Answers: CC BY-SA 3.0
Answers: 2017-08-10T05:09:47.850Z
Answers: @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
Answers: Wissam Roujoulah
Answers: CC BY-SA 3.0
Answers: 2017-08-04T03:37:04.347Z
Answers: 2017-08-04T03:37:04.347Z
Answers: Wissam Roujoulah
Body: <p>I'm trying to implement <a href="https://github.com/carlosas/full-docker-for-symfony-3" rel="nofollow noreferrer">this</a> pre-cooked package of NGINX, PHP-FPM, MySQL, E-L-K.</p>
  <p>Everything is working fine but the connection with the database. It throws a ConnectionException.</p>
  <p>I'm not really sure if the program should try to access <em>172.18.0.4</em> instead of <em>172.18.0.3</em>, and where does this configuration comes from.</p>
  <p><strong>The IPs of my containers are:</strong></p>
  <blockquote>
  <p>/dockersymfony_elk_1 - 172.18.0.2</p>
  <p>/dockersymfony_nginx_1 - 172.18.0.5</p>
  <p>/dockersymfony_php_1 - 172.18.0.3</p>
  <p>/dockersymfony_db_1 - 172.18.0.4</p>
  </blockquote>
  <p><strong>The error:</strong></p>
  <blockquote>
  <p>[Doctrine\DBAL\Exception\ConnectionException]<br />
  An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'root'@'172.18.0.3' (using password: YES)</p>
  </blockquote>
  <p>What could be happenning? Is there a way to check a mysql connection manually?</p>
  
Comments: CC BY-SA 3.0
Comments: 2017-08-03T16:25:17.310Z
Comments: 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.
Comments: Dan Cornilescu
Comments: CC BY-SA 3.0
Comments: 2017-08-03T16:40:50.913Z
Comments: Please add the docker command that was used to start the container
Comments: 030
Comments: CC BY-SA 3.0
Comments: 2017-08-03T17:35:04.893Z
Comments: 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.
Comments: James Shewey
Tags: <docker><mysql>
Title: Can't connect to my dockerized MySQL
UserDisplayName: CarlosAS
ThreadText: # Can't connect to my dockerized MySQL
  
  (Asked by: username_0 on 2017-08-03)
  
  I'm trying to implement [this](https://github.com/username_0/full-docker-for-symfony-3) 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?
  
  **Tags:** docker, mysql
  
  > **Comments:**
  > **username_1**: 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.  
  > **username_2**: Please add the docker command that was used to start the container  
  > **username_3**: 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.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2017-08-04. Score: 3 | Accepted answer
  
  Since the response is `Access denied for user` so the port and the ip address is correct.
  
  I guess the only issue as @username_3 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
  
  > **Comments:**
  > **username_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 :)  
  > **username_4**: @username_1 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  
  
  ---
  
  ### Answer by username_3 on 2017-08-03. Score: 1
  
  First, [confirm that the container is actually listening for connections and has properly bound to the interface](https://stackoverflow.com/questions/40350456/docker-any-way-to-list-open-sockets-inside-a-running-docker-container). 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
  
  
  ---
  
  