Docker进入mysql容器

时间:2022-06-17
本文章向大家介绍Docker进入mysql容器,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

先启动mysql服务,启动mysql后,如果想进入mysql的命令行,执行如下命令

[root@izbp163wlhi02tcaxyuxb7z ~]# docker exec -it mysql1 bash //mysql1是我启动的mysql服务的name

root@654c15160c66:/# mysql -uroot -p
Enter password: 
//输入密码即可
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 9
Server version: 8.0.11 MySQL Community Server - GPL

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.

mysql> 

//已经进入命令行模式