Search code examples
mysqldockerintellij-idea

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


Currently unable to connect from Intellij to mySql running locally on docker container on ubuntu.

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| tasklogs           |
+--------------------+

+----------+-----------+------+
| DATABASE | HOST      | USER |
+----------+-----------+------+
| tasklogs | localhost | dev  |
| tasklogs | localhost | root |
+----------+-----------+------+

+-----------------------------------------------------------+
| Grants for dev@localhost                                  |
+-----------------------------------------------------------+
| GRANT USAGE ON *.* TO `dev`@`localhost`                   |
| GRANT ALL PRIVILEGES ON `tasklogs`.* TO `dev`@`localhost` |
+-----------------------------------------------------------+

docker ps -a:

enter image description here

When I connect via intellij:

enter image description here

i.e. "The specified database user/password combination is rejected: [28000][1045] Access denied for user 'dev'@'localhost' (using password: YES)"

I am putting in the right password.

Any help really appreciated.

Thanks,


Solution

  • 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