docker pull mysql:5.6
docker images
在opt下创建文件夹
cd /opt/
mkdir mysql_docker
cd mysql_docker/
echo $PWD
启动mysql容器,在var/lib/docker/containers/下查看容器
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:5.6
cd /var/lib/docker/containers/
查看mysql进程
docker ps -a
进入mysql容器,并登陆mysql
docker exec -it mysqlserver bash
mysql -uroot -p
输入:123456
开启远程访问权限
use mysql;
select host,user from user;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
docker stop mysqlserver
docker ps -a
docker restart 容器id
|