Home >Database >Mysql Tutorial >How to solve Docker MySQL cannot be accessed by the host
Docker
After starting the MySQL
container, create a localhost
access user:
create user test@localhost identified by 'test';
However, the user cannot log in through the host machine:
mycli -u test
MySQL# in
Docker ##The user who created
localhost can only be accessed within
Docker and cannot be accessed externally.
root can be accessed on the host machine, it is because there are two
root by default, which are:
root@localhost
root@%
# #And
test has only one localhost
:
3 Solution
Or create test@172.17.0.1
: <pre class="brush:sql;">create user test@% identified by &#39;test&#39;;
create user test@172.17.0.1 identified by &#39;test&#39;;</pre>
The above is the detailed content of How to solve Docker MySQL cannot be accessed by the host. For more information, please follow other related articles on the PHP Chinese website!