![]() Used the above Ip in the application-dev.yml as below ( URL post resolve of the $ looks something as below But the IP changes to next highrt post the docker-compose down ex: 172.19.0.1) url: jdbc:mysql://172.18.0.1:3306/abcDB?useUnicode=true&characterEncoding=utf8&useSSL=falseĪnd Also updated the bind-address = 0.0.0.0 in the /etc/mysql//mysqld.cnf and from the mysql command line allow the root user to connect from any Ip.īelow were the only commands worked for mysql-8.0 as other were failing with error syntax check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'abcd'' at line 1 GRANT ALL PRIVILEGES ON *.* TO mysql. Our tomcat-application was using a application-dev.yml file with jdbc config variable to connect to the mysql, say something like url: jdbc:mysql://db:3306/abcDB?useUnicode=true&characterEncoding=utf8&useSSL=falseĬommand: '-default-authentication-plugin=mysql_native_password'Īs we wanted to connect our docker-compose tomcat service from the local mysql we tried the below routes.ĭocker inspect | grep Gateway which returned the ip Gateway ip value as` "Gateway": "", So as alternative and quick fix we thought to use local mysql configured on the local laptop with Ubuntu and docker-compose. We had a same scenario where we wanted to setup a Development local machine setup for the services where a developer can just make docker-compose up -d and use all the latest dev builds in his local machine.īut we started facing issues while connecting our tomcat based web service configured as service in the docker-compose.yml to **mysql-8.0** service within the docker-compose. Then, point in your hibernate.properties to mysql as this: localhost:3306 In your my.cnf search for bind-address that should be 0.0.0.0 (consider security issues if your server has public IP).Īs an alternative you can bring to the container the same networking as your host, in order to share the localhost, so the container will find mysql there. Take into account that that IP is fixed as long as the docker network still the same (the network is created by docker-compose, and it is not removed unless you do docker-compose down)Īlso, check that your MySQL is listening to all of its interfaces. So inside your docker application point to MySQL as this: 172.18.0.1:3306 (maybe in a configuration file). ![]() So you always want to set the database host to 127.0.0.1. If you use docker-compose.yml version: "3" it's probably that that IP is: 172.18.0.1, but confirm it searching for the "Gateway" of your container (your host): docker inspect | grep Gateway DB Host (127.0.0.1): This should always be your localhost (127.0.0.1) the reason is that your database client (TablePlus in this case) will create an ssh connection and then forward a port you specify (next field) from your local machine to the remote database server via ssh. Find the host machine ip in the docker network.
0 Comments
Leave a Reply. |