Datagrip cannot access containerized database
I cannot find a way to connect to MySQL database through Datagrip
I get the error
DBMS: MySQL (no ver.)Case sensitivity: plain=mixed, delimited=exactConnection refused: connect.
The database was taken from `docker pull mysql` and for creating the container I did `docker run -d --network host --name todo-db -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=user -e MYSQL_PASSWORD=paswword -e MYSQL_DATABASE=todo mysql` every time I try to connect I get this error
Maybe I'm doing something wrong.. I could'nt find any documentation for this at all.
What I have tried to solve this problem
- Change `localhost` to 127.0.0.1
- Open the port of the container with `docker run -d --network host --name todo-db -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=user -e MYSQL_PASSWORD=paswword -e MYSQL_DATABASE=todo0 -p 3306:3306 mysql`
- Try to connect to the container IP with the command `docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' todo-db-1` which outputs nothing
Firewall is deactivated, what else can I do to connect? It works with cli but not with Datagrip
Please sign in to leave a comment.
Hello,
Does connection work from command line outside IDE?
yes it works with cli outside the ide and inside the ide (with the docker plugin)
Please upload the idea log from Help - Show Log in Files onto https://uploads.jetbrains.com/
We'll check the log and get back to you.
Hello I have uploaded the log that you requested
Upload id: 2023_02_27_LMuHcq1hdsvjDNQcFDe8ZK (file: idea.log)
Do you use any antivirus software or firewall? Please try to temporarily disable it.
i do not use any antivirus software, as i mentioned previously even my firewall is disabled
What command do you use in CLI?
I tried these two
Is it possible to start docker first and then try to use "mysql" command in CLI to connect to DB located in Docker?
should work fine.
Did you image start fine? Is the container healthy?