Home > Operation and Maintenance > Docker > 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
Release: 2022-07-08 15:33:11
Original
4493 people have browsed it

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
Copy after login

Login mysql

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

Authorization

 GRANT ALL ON . TO ‘root’@’%’;
Copy after login

Refresh permissions

flush privileges;
Copy after login
Copy after login

2. Change encryption rules

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

3. Update the root user password

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

Refresh permissions

flush privileges;
Copy after login
Copy after login

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!

Related labels:
source:php.cn
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