yum install docker-io -y
docker -v
service docker start
chkconfig docker on
echo "OPTIONS='--registry-mirror=https://mirror.ccs.tencentyun.com'" >> /etc/sysconfig/docker
systemctl daemon-reload
service docker restart
docker pull mysql
docker images
docker run -d -p 3306:3306 --name mysql -P -e mysqld -e MYSQL_ROOT_PASSWORD=123456 -v /mysql_data:/var/lib/mysql mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
docker ps -a
yum install telnet -y
telnet localhost 3306
ls /mysql_data/
https://www.cnblogs.com/adolfmc/p/7109342.html
https://cloud.tencent.com/developer/article/1017063
移除docker:docker rm mysql
停止容器:docker stop mysql
docker exec -it mysql /bin/bash
cd /etc/mysql/mysql.conf.d/
echo 'max_allowed_packet=32M' >> mysqld.cnf
show VARIABLES like '%max_allowed_packet%';
查看日志:
docker logs -f -t --tail 10 容器ID
错误处理:
连接Docker启动的mysql出现:ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded
解决方案(在linux环境下):
1.进入mysql容器
docker exec -it mysql /bin/bash
2.进入mysql
mysql -uroot -p123456
3.修改密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
链接:https://www.jianshu.com/p/f641e4c5d7fd
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。