拉取镜像
docker pull mysql:latest
创建安装文件夹
cd /
mkdir mysql_docker
cd mysql_docker
echo $PWD
启动mysql容器
docker run --name mysqlserver -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d -i -p 3306:3306 mysql:latest
查看容器运行状态
docker ps
进入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