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:
When I connect via intellij:
ie "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,
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:
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"
If none of the answers above worked for you:
In my case I had forgotten to expose the port, but in addition I had mySQL running locally as well.
So in order to debug this I did the following:
mysql -h localhost -P 3306 --protocol=tcp -u root --password=password
The above was successful, and I managed to login through the terminal.
Important note: when the container was done, the same command allowed me to login to the local (non-containerized) mySQL. Thus I was trying to identify a potential conflict between the two, since both had the same port.
Solution: I exposed the DB in the container in a different port 3309 and thus managed to connect successfully.
ports:
- "3309:3306"
Also checking the following might help as well:
enabledTLSProtocols: TLSv1,TLSv1.1,TLSv1.2,TLSv1.3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.