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 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!test@172.17.0.1
: create user test@% identified by 'test';
create user test@172.17.0.1 identified by 'test';