Reputation:
i have ran those commands:
docker run --name mysql-standalone -e
MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=test -e MYSQL_USER=sa -e MYSQL_PASSWORD=password -d mysql:5.6
then
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
35da304532c8 mysql:5.6 "docker-entrypoint.s…" 4 hours ago Up 4 hours 3306/tcp mysql-standalone
docker exec -it mysql-standalone bash
root@35da304532c8:/# mysql -uroot -p -A
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.51 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
but while trying to connect via dbeaver i get somethins like this
where am i doing wrong?
Upvotes: 6
Views: 10483
Reputation: 1683
Stop your existing mysql container and remove it with:
docker stop <container id>
docker rm <container id>
Then run container again with port mapping. Use -p 3306:3306
to map container port into host machine port.
The full command will be like this:
docker run --name mysql-standalone -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=test -e MYSQL_USER=sa -e MYSQL_PASSWORD=password -p 3306:3306 -d mysql:5.6
This time dbeaver connection should work.
Explanation
Your mysql server is running in port 3306 inside the docker container. This port is inside that container, not your host machine. Dbeaver does not know about that container, it tries to connect with your host machine (your laptop/pc) port. Using -p 3306:3306
you map the container port with your computers port.
Upvotes: 11