docker下安装使用mysql
1. docker 拉取mysql 镜像
docker pull mysql
查看拉取的镜像
docker images
2.运行mysql 镜像
docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123 -d mysql
查看运行状态
docker ps -a (status为 up * ** 为正常运行)
3.进入容器内开启mysql远程连接权限
docker exec -it 108df12296a4 /bin/bash (108df12296a4 对应 状态查看中的CONTAINER ID)
mysql -u root -p 连接mysql
执行开启mysql远程连接权限sql
GRANT ALL ON *.* TO 'root'@'%';
flush privileges;
修改加密规则mysql5.7及之前 版本不用zhi
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';
flush privileges;
4.远程连接测试