Solve the problem that docker MySQL cannot be accessed by the host

Time:2022-1-7

1 problem description

Dockerstart-upMySQLAfter the container, create alocalhostUsers accessed:

create user [email protected] identified by 'test';

However, you cannot log in through this user on the host:

mycli -u test

Solve the problem that docker MySQL cannot be accessed by the host

2 reasons

stayDockerMediumMySQLestablishlocalhostUsers can onlyDockerInternal access, not external access.

As for why it can be accessed on the hostroot, because there are two by defaultroot, respectively:

Solve the problem that docker MySQL cannot be accessed by the host

andtestonly onelocalhost

Solve the problem that docker MySQL cannot be accessed by the host

3 solution

establish[email protected]%Or create[email protected]You can:

create user [email protected]% identified by 'test';
create user [email protected] identified by 'test';

Recommended Today

C + + : file operation

File operation is an indispensable part of program development. Any software that needs data storage needs file operation. File operations include opening, reading and writing files. (1) Stream class library in C + + C + + language defines special class libraries for standard input and output of different types of data. The class libraries […]