Problem:
The database installed by docker is not connected for a period of time, and it cannot be connected again
Reason:
The default connection timeout period of the database is 88 hours;
modify the configuration to 365 days
Enter the mysql container
#查看mysql容器名称
docker ps -a;
#进入mysql容器
docker exec -it mysql容器名称 bash;
Modify the configuration file
#切换目录
cd /etc/mysql/mysql.conf.d
#修改文件
vim mysqld.cnf
#在 [mysqlid] 最后一行添加配置
sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
或者
wait_timeout=1814400
After the modification is complete, restart the mysql container.
When modifying the configuration file in the container, the vi command is not installed in the docker instance
root@a788e8e543df:/etc/mysql# vi mysql.cnf
bash: vi: command not found
Solution:
Use the apt-get command to install (the root user must enter the docker)
The command is as follows: apt-get install vim
An error will be reported for the first execution:
Solution:
Execute once:
After apt-get update,
execute apt-get install vim again