docker安装mysql
- 访问 MySQL 镜像库地址:https://hub.docker.com/_/mysql?tab=tags 。
编辑镜像下载地址:
vi /etc/docker/daemon.json
{"registry-mirrors":["https://reg-mirror.qiniu.com/"]}
报错:docker报错Get https://registry-1.docker.io/v2/: x509: certificate has expired or is not yet valid
yum -y install ntpdate
本地系统时间错误导致报错证书过期,输入下面语句同步一下时间
ntpdate cn.pool.ntp.org
date
3.拉取镜像:docker pull mysql:8.0.23
4.查看安装:docker images
5.运行mysql容器:
docker run -itd --restart=always --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password mysql
-
命令查看是否安装成功: docker ps
-
登录提示caching_sha2_password问题解决方法
进入容器:
docker exec -it dd681cba0de2 /bin/bash
或者:docker exec -it mysql bash
登录mysql:
mysql -u root -p 输入密码:password
alter user root identified with mysql_native_password by ‘password’;
刷新:flush privileges;
退出:quit()