title: How to connect to MySQL created with docker to another port (not port 3306)?
body: <p>I already have installed mySql on my pc so port 3306 is already busy. This is the reason why I have to use a different port from 3306. I want to be able to connect with my machine to my docekr instance without using docker commands so I will be able to connect to that instance with my application (Spring web app).</p>
  
  <p>Docker commands that I used:</p>
  
  <pre><code>docker run --name jt-mysql -e MYSQL_ROOT_PASSWORD=password -p 3307:3307 -d mysql
  </code></pre>
  
  <p>Then I tried to connect to that istance with:</p>
  
  <pre><code>mysql --user=root -P 3307 -p
  </code></pre>
  
  <p>In this case I get the following error:</p>
  
  <blockquote>
    <p>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
    password: YES)</p>
  </blockquote>
  
  <p>Please note that if I tried to use the instance installed on my pc it works, using with:</p>
  
  <pre><code>mysql --user=root -P 3306 -p
  </code></pre>
  
  <p>Other information about my docker instance using:</p>
  
  <pre><code>docker ps
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <p>f52a94aa63da        mysql               "docker-entrypoint.s…"   4
    minutes ago       Up 4 minutes        3306/tcp, 33060/tcp,
    0.0.0.0:3307->3307/tcp   jt-mysql</p>
  </blockquote>
  
  <p>with status insided my docker image (entering using docker commands) I get:</p>
  
  <pre><code>Connection id:      11
  Current database:   
  Current user:       root@localhost
  SSL:            Not in use
  Current pager:      stdout
  Using outfile:      ''
  Using delimiter:    ;
  Server version:     8.0.19 MySQL Community Server - GPL
  Protocol version:   10
  Connection:     Localhost via UNIX socket
  Server characterset:    utf8mb4
  Db     characterset:    utf8mb4
  Client characterset:    latin1
  Conn.  characterset:    latin1
  UNIX socket:        /var/run/mysqld/mysqld.sock
  Binary data as:     Hexadecimal
  Uptime:         16 min 50 sec
  </code></pre>
  
  <p>using env command:</p>
  
  <pre><code>HOSTNAME=f52a94aa63da
  MYSQL_ROOT_PASSWORD=password
  PWD=/
  HOME=/root
  MYSQL_MAJOR=8.0
  GOSU_VERSION=1.7
  MYSQL_VERSION=8.0.19-1debian9
  TERM=xterm
  SHLVL=1
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  _=/usr/bin/env
  </code></pre>