mkdir -p datadir
mkdir -p {data,logs,conf}
docker pull mysql:5.7
docker run -p 3306:3306 --name mysql -v /data/datadir/conf:/etc/mysql/conf.d -v /data/datadir/logs:/logs -v /data/datadir/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
进入容器:
docker exec -it 62349aa31687 /bin/bash
进入mysql:
mysql -uroot -p
授权:
mysql> GRANT ALL ON *.* TO 'root'@'%';
刷新权限:
mysql> flush privileges;
更新加密规则:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
更新root用户密码:
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH
mysql_native_password BY '123456';
刷新权限:
mysql> flush privileges;