1、docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
a076a628af6f: Pull complete
f6c208f3f991: Pull complete
88a9455a9165: Pull complete
406c9b8427c6: Pull complete
7c88599c0b25: Pull complete
25b5c6debdaf: Pull complete
43a5816f1617: Pull complete
1a8c919e89bf: Pull complete
9f3cf4bd1a07: Pull complete
80539cea118d: Pull complete
201b3cad54ce: Pull complete
944ba37e1c06: Pull complete
Digest: sha256:feada149cb8ff54eade1336da7c1d080c4a1c7ed82b5e320efb5beebed85ae8c
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
2、docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest c8562eaf9d81 7 weeks ago 546MB
3、启动:docker run -d -p 3306:3306 --name fbmysql -e MYSQL_ROOT_PASSWORD=028911 mysql:latest(fbmysql是自定义名字)
4、docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
569028be8f00 mysql:latest "docker-entrypoint.s…" 20 minutes ago Up 20 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp fbmysql
5、docker exec -it 569028be8f00 bash(进入容器)
在容器里登录mysql:mysql -u root -p
登录mysql之后执行:(允许远程访问)
alter user 'root'@'%' identified with mysql_native_password by '028911';
6、利用远程工具连接