Home  >  Article  >  Operation and Maintenance  >  What to do if docker reports error 2003 when connecting to mysql

What to do if docker reports error 2003 when connecting to mysql

WBOY
WBOYOriginal
2022-07-08 15:33:114449browse

Solution: 1. Enter the mysql container of docker and use "GRANT ALL ON . TO 'root'@'%';" to authorize the user; 2. After refreshing the permissions, use "ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;" Change the encryption rules; 3. Update the root user password and refresh the permissions.

What to do if docker reports error 2003 when connecting to mysql

The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.

What to do if docker connects to mysql and reports error 2003

1. Check the reason for the error:

The default configuration file mysql database my.cnf (linux, docker The bind-address in (below) defaults to 127.0.0.1

What to do if docker reports error 2003 when connecting to mysql

2. Solve the error:

1. First enter the mysql container of docker, enter the password

What to do if docker reports error 2003 when connecting to mysql

and the command is as follows:

Enter the mysql container:

docker exec  -it mysql  bash

Login mysql

mysql -uroot -p;(注意一定要打分号,分号是终止命令符号)

Authorization

 GRANT ALL ON . TO ‘root’@’%’;

Refresh permissions

flush privileges;

2. Change encryption rules

ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘password’ PASSWORD EXPIRE NEVER;

3. Update the root user password

 ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘123456’;(密码是自己定义的)

Refresh permissions

flush privileges;

Execute the above naming, step by step, and the 2003 error will be resolved Solved

Recommended learning: "docker video tutorial"

The above is the detailed content of What to do if docker reports error 2003 when connecting to mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:Can docker mount files?Next article:Can docker mount files?