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 1 year has passed since last update.

メモ:Dockerコンテナ内にMySQLのタンプファイルをコピーしてリストア

Posted at

メモメモ

コンテナ名を調べる

$ docker compose ps
NAME                 COMMAND                  SERVICE             STATUS              PORTS
xxxxxxxxxxxx-app-1   "/usr/sbin/apachectl…"   app                 running             0.0.0.0:8081->80/tcp
xxxxxxxxxxxx-db-1    "docker-entrypoint.s…"   db                  running             3306/tcp

ファイルをコピーする

$ docker cp xxxxxxxxxxxx.dump.sql xxxxxxxxxxxx-db-1:/tmp/

xxxxxxxxxxxx-db-1は前項で調べたコンテナ名

コンテナ内へ侵入

$ docker exec -it xxxxxxxxxxxx-db-1 bash

リストア実行

# mysql -u root -p -D app < /tmp/xxxxxxxxxxxx.dump.sql
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?