Unable to connect from Intellij to mySql running in docker container - "specified database user/password combination is rejected"

Solution

You didn't map your port with the localhost so you can't use localhost this is why couldn't do it

ports:
  - "3306:3306"

As @danblack mentioned, I needed to connect via tcp.

1) To get the IP of the container:

docker inspect mysql1

2) I changed the mysql user to allow access from all locations (as mentioned here):

'dev'@'%' it was 'dev'@'localhost' previously

That did the trick:

enter image description here