Home > Database > Mysql Tutorial > body text

How to solve Docker MySQL cannot be accessed by the host

WBOY
Release: 2023-05-26 13:55:06
forward
1593 people have browsed it

1 Problem description

DockerAfter starting the MySQL container, create a localhost access user:

create user test@localhost identified by 'test';
Copy after login

However, the user cannot log in through the host machine:

mycli -u test
Copy after login

How to solve Docker MySQL cannot be accessed by the host

2 Reason

MySQL# in Docker ##The user who created localhost can only be accessed within Docker and cannot be accessed externally.

As for why

root can be accessed on the host machine, it is because there are two root by default, which are:

  • root@localhost

  • root@%

How to solve Docker MySQL cannot be accessed by the host# #And

test

has only one localhost:

How to solve Docker MySQL cannot be accessed by the host3 Solution

Create

test@%

Or create test@172.17.0.1:

create user test@% identified by 'test';
create user test@172.17.0.1 identified by 'test';
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template