0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dockerコンテナ(mysql)に接続する

Posted at

Dockerコンテナ(mysql)にアクセスする

起動中のコンテナを確認する

$docker-compose ps
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                                NAMES
847c99b0929c        nginx:latest                   "nginx -g 'daemon of…"   20 minutes ago      Up 20 minutes       0.0.0.0:8080->80/tcp                 docker_php_nginx_1
5e2039b237df        docker_php_php                 "docker-php-entrypoi…"   20 minutes ago      Up 20 minutes       9000/tcp                             docker_php_php_1
8193d899b38d        phpmyadmin/phpmyadmin:latest   "/docker-entrypoint.…"   20 minutes ago      Up 20 minutes       0.0.0.0:8888->80/tcp                 docker_php_phpmyadmin_1
f4ff8b6b8ac3        mysql:5.7                      "docker-entrypoint.s…"   22 minutes ago      Up 20 minutes       33060/tcp, 0.0.0.0:13306->3306/tcp   docker_php_db_1

ホストPCからコンテナ(mysql)に接続する

CONTAINER IDを指定

$docker exec -it f4ff8b6b8ac3 bash

mysqlに接続

root@f4ff8b6b8ac3:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
5 rows in set (0.03 sec)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?