Home > Article > Operation and Maintenance > What to do if docker reports error 2003 when connecting to mysql
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.
The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.
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
2. Solve the error:
1. First enter the mysql container of docker, enter the password
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!