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?

Docker上のMySQLをphpMyAdminで簡単にGUI操作

Posted at
  • Docker v24

はじめに

Dockerで作成したデータベースの中身を確認、操作する際に、毎回MySQLのコンテナに入ってコマンドを叩いていたのですがとても面倒でした。

phpMyAdminのコンテナを作ると簡単にGUI操作ができて便利でしたので紹介します。

phpMyAdminのコンテナを追加

compose.yamlにphpMyAdminのコンテナ定義を追記します

services:
  mysql:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
    ports:
      - 3306:3306
    volumes:
      - mysql-data:/var/lib/mysql

# phpMyAdminコンテナを追記
  phpmyadmin:
    image: phpmyadmin
    depends_on: # 依存関係
      - mysql
    environment:
      - PMA_ARBITRARY=1 # 任意のホストを設定
      - PMA_HOSTS=mysql # ホスト名
      - PMA_USER=root # ユーザー名
      - PMA_PASSWORD=${MYSQL_ROOT_PASSWORD} # パスワード
    ports:
      - "3001:80"
    volumes:
      - pma-sessions:/sessions

volumes:
  mysql-data:
  pma-sessions:

コンテナ起動後http://localhost:3001/index.phpにアクセスすると表示されます。

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?