进入Mysql容器

2018-07-04  本文已影响0人  阿桃_28e7

[root@localhost ~]# docker ps -a | grep mysqle548b11fdf3e XXX.com/mysql:latest "docker-entrypoint.sh" 11 days ago Up 11 days 0.0.0.0:3308->3306/tcp XXX_mysql_1[root@localhost ~]# docker logs -ft XXX_mysql_1^C #退出docker ps[root@localhost ~]# docker exec --helpUsage:docker exec [OPTIONS] CONTAINER COMMAND [ARG...]Run a command in a running container -d, --detach Detached mode: run command in the background --detach-keys Override the key sequence for detaching a container --help Print usage -i, --interactive Keep STDIN open even if not attached --privileged Give extended privileges to the command -t, --tty Allocate a pseudo-TTY -u, --user Username or UID (format:[:])

[root@localhost ~]# ^C #docker exec --help

[root@localhost ~]# docker exec -it some_mysql_1 bash #容器名不正确

Error response from daemon: No such container: some_mysql_1

[root@localhost ~]# docker exec -it XXX_mysql_1 bash #进入Mysql命令窗口

##########先要登录Mysql服务器,才能执行数据库查询###############

root@e548b11fdf3e:/# show databases

bash: show: command not found 

root@e548b11fdf3e:/# show tables;

bash: show: command not found

root@e548b11fdf3e:/# mysql -uroot -p123456

Warning: Using a password on the command line interface can be insecure.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

root@e548b11fdf3e:/# mysql -uroot -p     

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

root@e548b11fdf3e:/# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 427

Server version: 5.6.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> show databases;

+--------------------+

| Database          |

+--------------------+

| 数据库1            |

| 数据库2            |

| 数据库3            |

| 数据库4            |

| 数据库5            |         

| my_db              |

+--------------------+

12 rows in set (0.00 sec)

mysql> use my_db 

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+-------------------------+

| Tables_in_my_db        |

+-------------------------+

| t_XXX                  |

| t_XXX                  |

| t_XXX                  |

| t_users                |

| t_users_area            |

| t_users_detail          |

| t_users_function        |

| t_users_functions      |

| t_users_log            |

| t_users_roles          |

| t_users_roles_functions |

| t_users_roles_users    |

+-------------------------+

22 rows in set (0.00 sec)

mysql> 

上一篇下一篇

猜你喜欢

热点阅读