$ sudo docker ps # 出现以下信息说明运行成功 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5f32c38e2309 mysql:8.3.0 "docker-entrypoint.s…" 11 seconds ago Up 9 seconds 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp test_mysql
四、进入docker的mysql容器,连接mysql服务器
1 2 3 4 5 6 7 8 9 10 11 12 13 14
$ sudo doccker exec -it 容器ID /bin/bash $ mysql -u 用户名 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.3.0 MySQL Community Server - GPL
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.