Problem Description:
the reason for the pit I encountered in learning docker is that the MySQL image used in the video is 5.7, and I use more than 8.0 (8.0.16) </ font>
Error code
Cause analysis:
Start from the third step, analyze step by step, and directly look at the solutions
1. Pull image
I pulled more than 8.0, so I encountered this pit
docker pull mysql:8.0.16
2. View mirror
docker images
3. Run container
docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.16
After running, you can see the container ID, but it is empty when viewed with docker PS
4. View container
docker ps
5. View all containers
docker ps -a
6. View log analysis
docker logs 容器id
7. Cause
The configuration location of MySQL is wrong when running the container. The configuration location of MySQL 5.7 is/etc/MySQL. The configuration location above MySQL 8.0 is/etc/MySQL/conf.d. just modify the configuration location according to the MySQL version
Solution:
1. Delete container
docker rm Container id or NAME
2. Modify the configuration of the run container
The conf configuration is modified as shown in the figure below
/mydata/mysql/conf:/etc/mysql
||
||
||
\/
/mydata/mysql/conf:/etc/mysql/conf.d
3. Rerun
Summary:
Mysql8.0 and above configuration
docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.16
Mysql5.7 configuration
docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
Read More:
- [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata
- Docker: How to Solve MYSQL8 & Navicat remote connection error
- [Solved] Docker Desktop Start MongoDb Error: Error: spawn C:\Windows\system32\cmd.exe; ENOENT
- [Solved] SQLSTATE[HY000] [2002] Connection refused to report an error when PHP connects to mysql in the docker container
- Docker mysql8 modify password
- After installing mysql5.7 on centos7, an error 1045 (28000) is reported: access denied for user ‘root’ @’localhost ‘(using PAS)
- [Linux Docker Mirror] MYSQL Run sql Script Error: Failed to open file ‘/home/mydatabase.sql‘, error: 2
- MYSQL Error 1045 (28000): access denied for user ‘root’ @’localhost ‘(using password: Yes)
- [Solved] there are special symbols in the initial password for installing MySQL in Hadoop, and an error is reported
- [Solved] Sqlyog always reports an error when creating a new connection.
- [Solved]Error 1054 (42s22): unknown column ‘password’ in ‘field list’ how to modify the password
- [Solved] docker mysql SQLSTATE[HY000] [2002] Connection refused
- [Solved] MySQL 8 Connect Navicat error: error 2059
- [Solved] pymysql.err.internalError: (1054, “Unknown column ‘LGD_xiaohong’ in ‘field list’”)
- [error][/usr/share/perl5/vendor_perl/MHA/SSHCheck.pm, ln63] Permission denied (publickey,gssapi-ke
- [Solved] There is a problem with mysql8.0 without password in Navicat connection
- [Solved] ERROR 1396 (HY000): Operation ALTER USER failed for ‘root‘@‘localhost‘
- Mysql5.7.18.1 Error 1054 (42S22): Unknown Column’password’ In’field List’ When Changing User Password
- [Solved] Error response from daemon: driver failed programming external connectivity on endpoint mysql
- MySQL character set error resolution: err=Error 3988: Conversion from collation utf8mb4_unicode_ci into utf8_general_ci impo