Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to Connect to Localhost (MySQL Workbench on MariaDB Docker)

I ran the following script:

docker run --detach --name mariadb-10.1.48 \
 --env MYSQL_USER=user --env MYSQL_PASSWORD='123' \
 --env MYSQL_ROOT_PASSWORD='abc' \
 -v /mnt/data/database/db_mysql:/var/lib/mysql \
 -v /mnt/data/database/db_mysql_config/my.cnf:/etc/mysql/my.cnf \
 mariadb:10.1.48

I already changed on my.cnf the following line "bind-address = 127.0.0.0" to:

bind-address=0.0.0.0

I can access locally via CLI. Using MySQL Workbench is giving me the error "Unable to connect to localhost"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

PS: My enviroment is the following:
Docker on Debian 11, i’m using Windows on the same network as the server trying to connect to the database using MySQL Workbench.

Please, what can i do?
Thank you…

>Solution :

You’re running it in a container so you’d have to forward the ports or connect to the container IP.

docker inspect will get you the container IP if that’s what you want.

Otherwise, change your docker command to the following to forward the port to your local machine:

docker run --detach --name mariadb-10.1.48 \
 --env MYSQL_USER=user --env MYSQL_PASSWORD='123' \
 --env MYSQL_ROOT_PASSWORD='abc' \
 -v /mnt/data/database/db_mysql:/var/lib/mysql \
 -v /mnt/data/database/db_mysql_config/my.cnf:/etc/mysql/my.cnf \
 -p 3306:3306 \
 mariadb:10.1.48

Note, if I’m understanding correctly your debian machine isn’t WSL. So, from windows, 0.0.0.0 is the IP of the machine running docker. 0.0.0.0 is all the available IPs of localhost

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading