安装docker
$ yum install docker
配置docker加速镜像
$ vi /etc/docker/deamon.json
# deamon.json 配置中科大pull镜像
#{
# "registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]
#}
重新启动docker
$ systemctl restart docker
搜索下载镜像
$ docker search
$ docker pull mysql:[tags]
docker基本操作(以mysql镜像为例)
# 查看镜像
$ docker images
# 查看(所有)容器
$ docker container list -a
# 创建容器并运行镜像
$ docker run --name mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mypassword mysql
# 进入docker容器(运行脚本)
# 容器NAME或容器ID
$ docker exec -it mysql /bin/bash
# 移除容器
$ docker rm [container name/ID]
# 停止/启动/重启 容器
$ docker stop [name/id]
$ docker start [name/id]
$ docker restart [name/id]
docker配置mysql 8.x
由于mysql 8.x采用了新的加密方式,直接连接会出现下面的错误:
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: ÕÒ²»µ
可以用以下语句查看mysql加密方式:
use mysql;
select user,plugin from user where user="root";
分别执行以下语句,修改所有用户的加密方式(%为所有用户)
# 修改加密规则
alter user root@ "%" identified by "mypassword" password expire never;
# 修改密码
alter user root@ "%" identified with mysql_native_password by "mypassword";
# 刷新权限
FLUSH PRIVILEGES;