Created
December 10, 2018 05:33
-
-
Save owen800q/e0fa3c845f3f866cb6b8ad726b1150da to your computer and use it in GitHub Desktop.
How to connect mysql-server 8 running on a docker container from the host using workbench
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When I tried to connect mysql server with root user that's running on a docker container | |
The warm message was shown Host '172.18.0.1' is not allowed to connect to this MySQL server | |
In MySQL database, execute this SQL script to list all existing database users | |
SELECT host, user FROM mysql.user; | |
It will display a table, for example like this: | |
+------------+------------------+ | |
| host | user | | |
+------------+------------------+ | |
| localhost | root | | |
| 127.0.0.1 | root | | |
| ::1 | root | | |
| localhost | mysql.sys | | |
| localhost | root | | |
| localhost | sonar | | |
+------------+------------------+ | |
The firsr line indicates that the root user is allowed only for localhost (dockcer container) to login | |
It has to contain a line with your database user and '%' to works (% means "every IP addresses are allowed"). Example: | |
+------------+------------------+ | |
| host | user | | |
+------------+------------------+ | |
| % | root | | |
+------------+------------------+ | |
make root user can connect itself from any IP addresses. | |
Update user set host = ‘%’ where host = ‘%’ and user = ‘root’ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment