title: docker mysql - Access denied for user
body: <p>I facing the typical issue of access denied for user@localhost.
  I am able to connect outside of docker but if I try to use within the docker container its causing access denied exception.</p>
  <p>Here is my sql output</p>
  <pre><code>select host,user from mysql.user;
  +-----------+---------------+
  | host      | user          |
  +-----------+---------------+
  | %         | assist_user   |
  | %         | root          |
  | %%        | assist_user   |
  | localhost | mysql.session |
  | localhost | mysql.sys     |
  | localhost | root          |
  | localhost | user          |
  +-----------+---------------+
  </code></pre>
  <p>Here is the queries I ran</p>
  <pre><code>GRANT USAGE ON *.* TO 'user'@'%' IDENTIFIED BY PASSWORD '*aaaaaaaaa'
  
  GRANT USAGE ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*aaaaa' 
  </code></pre>
  <p>What could be the issue ?</p>
  <pre><code>docker-compose.yml 
  version: '3.3'
  services:
    db:
      image: mysql:5.7.26
      container_name: mysql57
      restart: always
      environment:
        # So you don't have to use root, but you can if you like
        MYSQL_USER: 'user'
        # You can use whatever password you like
        MYSQL_PASSWORD: 'password'
        # Password for root access
        MYSQL_ROOT_PASSWORD: 'admin'
      ports:
        # &lt;Port exposed&gt; : &lt; MySQL Port running inside container&gt;
        - '3306:3306'
      expose:
        # Opens port 3306 on the container
        - '3306'
        # Where our data will be persisted
      volumes:
        - /home/my/mysql57:/var/lib/mysql
        # Source code
        - /home/my/:/home/dockerdev
    myapp:
      depends_on:
        - db
    environment:
      - WAIT_HOSTS=mysql57:3306
  </code></pre>