Datagrip cannot access containerized database

Answered

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

1
10 comments

Hello,

Does connection work from command line outside IDE?

0

yes it works with cli outside the ide and inside the ide (with the docker plugin)

0

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.

0

Hello I have uploaded the log that you requested
Upload id: 2023_02_27_LMuHcq1hdsvjDNQcFDe8ZK (file: idea.log)

0

Do you use any antivirus software or firewall? Please try to temporarily disable it.

0

i do not use any antivirus software, as i mentioned previously even my firewall is disabled

0

What command do you use in CLI?

0

I tried these two


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

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
0

Is it possible to start docker first and then try to use "mysql" command in CLI to connect to DB located in Docker?

1
docker run -dt -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=user -e MYSQL_PASSWORD=paswword -e MYSQL_DATABASE=todo0 -p 3306:3306 mysql 

 

 

should work fine.

Did you image start fine? Is the container healthy?

0

Please sign in to leave a comment.