docker mysql 忽然自动挂掉的解决方法:
创建docker 容器步骤:
docker pull mysql:5.7.17 1 . 启动 - 自定义配置 docker run --name mysql_01 \ -p 3306:3306 \ -v /home/test/docker/mysql/3306/conf:/etc/mysql/mysql.conf.d \ -v /home/test/docker/mysql/3306/data:/var/lib/mysql \ -v /home/test/docker/mysql/3306/logs:/var/log/mysql \ -e MYSQL_ROOT_PASSWORD=123456 \ -d mysql:5.7.17 docker exec -it 7388ab22f6ca sh mysql -uroot -p123456; use mysql; CREATE USER myuser@'%' IDENTIFIED BY '123456'; grant all on *.* to myuser@'%' with grant option; flush privileges;
某一天容器忽然停掉了。
我的解决方法:
ps -ef | grep mysqld
kill -9 20189
docker rm mysql_01
docker run --name mysql_01 \ -p 3306:3306 \ -v /home/test/docker/mysql/3306/conf:/etc/mysql/mysql.conf.d \ -v /home/test/docker/mysql/3306/data:/var/lib/mysql \ -v /home/test/docker/mysql/3306/logs:/var/log/mysql \ -e MYSQL_ROOT_PASSWORD=123456 \ -d mysql:5.7.17
----------------------------
docker logs mysql_01
执行如下操作:
docker ps -a 如果mysql_01 Exit(1) 表示有error
docker logs mysql_01 ./ibdata1 error: 11;
如果报错 参考: https://severalnines.com/blog/mysql-docker-containers-understanding-basics 【non-zero value】
重新登录,报错:
docker exec -it mysql_01 sh # mysql -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) # mysql -uroot -p123456 -P3306 -h 192.168.205.122 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.7.17 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
登录成功
原有的数据库配置和数据又可以使用了。