docker下部署mysql8.0

docker search mysql #查看mysql
docker pull mysql
在opt下创建文件夹

mkdir -p /opt/docker_mysql/{conf,data,logs}

cd /opt/docker_mysql

echo $PWD

docker run -itd --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -t mysql:latest

docker cp mysql:/etc/mysql/my.cnf ./conf/

启动mysql容器,在var/lib/docker/containers/下查看容器
docker run --name mysql \
-v $PWD/conf/my.cnf:/etc/mysql/my.cnf \
-v $PWD/logs:/logs \
-v $PWD/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
-d -i -p 3306:3306 \
--security-opt seccomp:unconfined \
--restart=always \
-t mysql:latest
进入mysql容器,并登陆mysql
docker exec -it mysqlserver bash
mysql -uroot -p
开启远程访问权限
命令:use mysql;
命令:select host,user from user;
命令:ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
命令:flush privileges;

查看docker日志
docker logs -f --tail 10 a4dac74d48f7

创建数据库

CREATE DATABASE `unicom` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

 

报错

ERROR 2026 (HY000): SSL connection error: error:0A000086:SSL routines::certificate verify failed

在/etc/my.cnf 文件下加入skip_ssl 可解决。

 

posted @ 2022-04-01 11:17  四毛二(ت)  阅读(264)  评论(0编辑  收藏  举报
/* 鼠标点击求赞文字特效 */