Host 'host.docker.internal' is not allowed to connect to this mysql server

Hello!
I am using Docker Desktop on Windows 10. Before installing Docker desktop, my jdbc url like below is connected to mysql successfully.

jdbc:mysql://192.168.200.51:3306/test?characterEncoding=utf8&serverTimezone=Asia/Seoul

But after installing docker desktop on windows 10, jdbc url won’t connect to mysql. And it throws the following error message.

host ‘host.docker.internal’ is not allowed to connect to this mysql server

I opened the hosts file and found the following statements are generated.

Added by Docker Desktop

192.168.200.51 host.docker.internal
192.168.200.51 gateway.docker.internal

How can my jdbc url be connected to the local mysql server with IP-adddress?
Any reply please. Thanks

1 Like

Hello,

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘password’;

Run the above command in your MySQL and try.

I am facing exactly the same issue. I provided the all privileges’ again to my database user, uninstall and reinstall mariaDB, uninstall my EAP-RHPAM application and installed in a different directory but nothing worked. I think the only option I left with is to format my laptop.

Won’t solve the problem either… As the “problem” actualy is mysql doing its job. You will need to check the Grants and from which ip range an account is allowed to login.

For instance, this allows that the root user can login from any ip using the specified password:

Clearly this only solves the “problem” for the database user named root. If you need a different user to access the database, you will need to replace TO 'root' with TO 'whatever_the_user_is' and if you want to lock the allowed ip range down, you need to replace @’% with @172.17.% or whatever the ip range of the docker network is.

1 Like
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'PASSWORD';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;