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 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’
- [Solved] MySQL Startup Error: Job for mysqld.service failed because the control process exited with error code
- [Solved] Job for mysqld.service failed because the control process exited with error code
- [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
- How to Solve mysqld — console command error
- [Solved] MySQL Install Error: GPG check FAILED
- MYSQL8 Startup Error: mysqld_safe error: log-error set to ‘/var/log/mariadb/mariadb.log‘
- MySQL Change password failure prompt: ERROR 1064(42000):You have an error in your SQL syntax: check the corresponds to your M
- Centos7 Initialize mysql Error: Could not open file ‘/usr/local/mysql/log/mysqld.log‘ for error logging: Per
- MYSQL Use cmd to change root password error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual tha
- IDEA maven Config MYSQL Connection Error: Could not create connection to database server.
- MYSQL Insert Data Error: check the manual that corresponds to your MySQL server version for the right syntax
- MYSQL syntax Error: check the manual that corresponds to your
- How to Check the most CPU consuming 50 queries in MYSQL
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- MySQL Build table error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL ser
- Mysql 8.0.13 Enabling remote access (ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th)
- [Solved] ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full comm
- [Solved] java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corres
- Mysqlclient Error: ERROR: No matching distribution found for mysqlclient/OSError: mysql_config not found