cd /opt/
mkdir mysql
cd mysql/
echo $PWD #输出/opt/mysql
启动mysql容器并查看
docker run --name emall_mysql -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
cd /var/lib/docker/containers/
ls
进入mysql容器
docker exec -it emall_mysql bash
mysql -u root -p
创建远程用户并修改密码验证规则
use mysql; #切换数据库
CREATE USER 'jason'@'%' IDENTIFIED BY '123456';
ALTER USER 'jason'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; #修改密码验证规则
GRANT ALL ON *.* TO 'jason'@'%'; #授予jason在所有主机的所有权限
flush privileges; #刷新权限