Docker安装Mysql

Docker安装Mysql

1、查询mysql

docker search mysql

2、安装mysql

docker pull mysql

3、查看镜像

docker images

4、在opt下创建文件夹

cd /opt/
mkdir mysql_docker
cd mysql_docker/
echo $PWD

5、启动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:latest

6、查看mysql进程

docker ps -a

7、进入mysql容器,并登陆mysql

docker exec -it mysqlserver bash
mysql -uroot -p

8、开启远程访问权限

use mysql;
select host,user from user;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
posted @ 2020-12-26 20:05  胖墩哥  阅读(1001)  评论(0编辑  收藏  举报