docker下进入mysql命令行

[root@VM_0_8_centos ~]# docker ps
CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                                                                                        NAMES
89c5b9c81e74        hub.c.163.com/library/mysql:latest   "docker-entrypoint..."   3 months ago        Up 3 months         0.0.0.0:3306->3306/tcp  

docker ps查看到mysql在运行  CONTAINER ID为89c5b9c81e74      

[root@VM_0_8_centos ~]# docker exec -it bash 89c5b9c81e74        
Error response from daemon: No such container: bash
[root@VM_0_8_centos ~]# docker exec -it bash 89c5b9c81e74
Error response from daemon: No such container: bash
[root@VM_0_8_centos ~]# docker exec -it 89c5b9c81e74  bash
root@89c5b9c81e74:/# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 141019
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

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> 
 

猜你喜欢

转载自blog.csdn.net/qq_38522268/article/details/87972453